From: Stefan Lang Date: 2006-02-06T07:16:10+09:00 Subject: Re: regex trick On Monday, February 06, 2006, at 7:08 AM, Alain FELER wrote: >I want to replace all ' by \' ? (I need it to do inserts in mysql). > > s = "j'ai" > > s.gsub!(/'/,'\'') > > p s ==> gives j'ai and not j\'ai as I want >Thanks for help. > s.gsub!("'", "\\\\'") should do the trick. Regards, Stefan -- Posted with http://DevLists.com. Sign up and save your time!