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 ne
JS's string.replace uses RegEx
Not necessarily:
var str = "O'Reilly's books";
alert(str.replace("'", "''", 'g'));
MDC's String replace reference:
The pattern can be a string or a RegExp
Mmm, my code above doesn't seem to work on IE6, so that will be:
str.replace(/'/g, "''")
like the others said, but using regexes for such simple operation is overkill.