From: Eric Hodel Date: 2006-02-08T07:16:04+09:00 Subject: Re: regex trick On Feb 7, 2006, at 1:43 PM, Alain FELER wrote: > Thank you very much for these four answers, but curiously none > works on my box ! : Incorrect. They all work. p "j\\'ai" "j\\'ai" puts "j\\'ai" j\'ai > Stefan Lang : s.gsub!("'", "\\\\'") gives "j\\'ai" not "j\'ai" puts "j'ai".gsub("'", "\\\\'") j\'ai > Timothy Hunter : s.sub(/'/) { '\\\'' } gives "j\\'ai" puts "j'ai".gsub(/'/) { '\\\'' } j\'ai > you : s.gsub!(/'/, "\\\\'") gives "j\\'ai" puts "j'ai".gsub(/'/, "\\\\'") j\'ai > and : s.gsub!(/'/) { "\\'" } gives "j'ai" puts "j'ai".gsub(/'/) { "\\'" } j\'ai -- Eric Hodel - drbrain@segment7.net - http://segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com