/ Published in: JavaScript
Expand |
Embed | Plain Text
//replace all whitespaces with underscore string.replace(new RegExp(/\s/g), '_'); //replace the word 'replace' with 'replaced' string.replace(/replace/g, 'replaced');
Comments
Subscribe to comments
You need to login to post a comment.

I always forget how this goes. The standard replace function only replaces the first instance in a string. But this is how you replace all occuring instances...