Tim Hunter
2/5/2006 10:22:00 PM
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.
irb(main):011:0> s = "j'ai"
=> "j'ai"
irb(main):012:0> puts s.sub(/'/) { '\\\'' }
j\'ai
=> nil
irb(main):013:0>