Regex for replacing a single-quote with two single-quotes
Try this:
yourstring = yourstring.replace(/'/g, "''")
You don't need to use RegExp.
String patterm version:
str.replace("'", "''", 'g')
RegExp pattern version:
str.replace(/'/g, "''")
Here you have some useful RegExp links:
- RegExp Tutorial
- Regular Expression Basic Syntax Reference
- RegExp Build&Testing Online Tool
str.replace(/'/g, "''");
Be sure to use the global match flag (g) so that you replace any and all occurrences in the string. More info here.