I'm not a RegExp Master..
Posted by Sandro Paganotti in
Ruby on Rails -
comments are closed
I’ve tried to create a regular expression that can trasform each aphostrophe to an escaped one but my attempt with irb driven me to a very strange behavior:
irb(main):001:0> "string ' with aphostrophe"
=> "string ' with aphostrophe"
irb(main):002:0> "string ' with aphostrophe".gsub("'","\\'")
=> "string with aphostrophe with aphostrophe"
Can you explain me why the expression I wrote duplicate everything after the aphostrophe ?
Can you lead me to a solution ?
Thank you guys.
Sandro


Comments
Keeto
Posted on January 24
twinwing
Posted on January 24
Peter Cooper
Posted on January 24
Sandro
Posted on January 24
Dominik
Posted on January 24
Radarek
Posted on January 24
Ryan
Posted on January 24