From: Jason Persampieri Date: 2002-12-20T16:48:49+09:00 Subject: Re: Few question about IO > does not work for me: > irb(main):032:0> ": dbl dup + > ;".gsub(%r[(\s|^)\+(\s|$)], %Q[\1:plus:\2]) > => ": dbl dup\001:plus:\002;" > > something is wrong with \1 and \2 > %Q is equivalent to double-quoting. %q is equivalent to single-quoting irb(main):002:0> "\1" "\001" irb(main):003:0> '\1' "\\1" irb(main):004:0> %Q(\1) "\001" irb(main):005:0> %q(\1) "\\1" When you call gsub, you must use the single-quoted form. This 'gotcha' just bit me earlier today. Jason PS. It feels really good to be able to actually help others for a change. ;)