Saturday, 7 September 2013

Regex for single quote within single quotes

Regex for single quote within single quotes

OK, so this is what I'm trying to do :
I've got a complete SQL script
Some of the 's inside the values have not been properly escaped
e.g. if we have 'children's shoes', I want to replace it with 'children\'s
shoes'
So, any suggestions? (I've tried various workarounds but I don't seem to
be able to get it right...)



UPDATE:
'.+?' sure matches the values - but how do I match the 'ss within the values?
Here's a RegExr example of what I'm trying to match : http://regexr.com?368bo



UPDATE II :
OK, I think I'll go with [a-z]'s. It seems like it's capturing what I
need. And replace with $1\'s.

No comments:

Post a Comment