Tuesday 17 October 2017

javascript - Regex for replacing a single-quote with two single-quotes

itemprop="text">

I'm running into an issue that I think
is being caused by needing to double-up on some single quotes inside a string. However,
JS's string.replace uses RegEx, and I've never built a RegEx by
hand.



Can someone help me build a RegEx to find
a single quote and replace it with two single quotes?



Answer




Try
this:




yourstring =
yourstring.replace(/'/g, "''")


No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...