Return to Snippet

Revision: 29307
at June 3, 2011 20:22 by fengelz

Updated Code
//replace all whitespaces with underscore
string.replace(new RegExp(/\s/g), '_');

//replace the word 'replace' with 'replaced'
string.replace(/replace/g, 'replaced');

Revision: 29306
at July 26, 2010 18:08 by fengelz

Updated Code
string.replace(new RegExp(/\//g), '_');

string.replace(/replace/g, 'replaced');

Revision: 29305
at July 26, 2010 18:07 by fengelz

Initial Code
return string.replace(new RegExp(/\//g), '_');

return string.replace(/replace/g, 'replaced');

Initial URL

Initial Description

Initial Title
Javascript string replace (all occurrences)

Initial Tags
javascript, replace

Initial Language