Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string.replace() 1

Status
Not open for further replies.

TheConeHead

Programmer
Aug 14, 2002
2,106
US
how can I replace for a variable. I am using:

string.replace(/'/g,"''"); to replace a one single quote with two single quotes... how can I have a var in the / / instead of a '?



[conehead]
 
like so:
Code:
var pattern = "'";
var re = new RegExp(pattern, "g");
string.replace(re, "\"");

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top