Created
September 26, 2011 11:20
-
-
Save fengelz/1242042 to your computer and use it in GitHub Desktop.
Javascript String Replace (All Occurrences)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//replace all whitespaces with underscore | |
string.replace(new RegExp(/\s/g), '_'); | |
//replace the word 'replace' with 'replaced' | |
string.replace(/replace/g, 'replaced'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment