To replace all occurrences in a string use the “g” modifier without double quote like this
var strvar = “one two one”;
strvar = strvar.replace(/one/g,”1″);
the output of the strvar would be “1 two 1″
To replace all occurrences in a string use the “g” modifier without double quote like this
var strvar = “one two one”;
strvar = strvar.replace(/one/g,”1″);
the output of the strvar would be “1 two 1″
This entry was posted on Saturday, October 10th, 2009 at 9:35 am and is filed under Javascript. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Fusion theme by digitalnature | powered by WordPress
Entries (RSS) and Comments (RSS)