From: Warren Brown Date: 2003-07-24T04:28:34+09:00 Subject: Re: String substitution without RegEx Andreas, > Exactly. The only solutions I can think of: > 1) use regex_escape() for the string that should > be replaced, and remove backreferences in the > replacement string manually > 2) do it char by char, like in C. How about using the block form of String#gsub in combination with Regexp.escape: irb(main):001:0> "foo.bar".gsub(Regexp.escape('.')) { '.\1' } => "foo.\\1bar" This eliminates the problems with backreferences in the replacement string. I hope this helps! - Warren Brown