Created
January 6, 2014 13:24
-
-
Save unknownuser88/8282850 to your computer and use it in GitHub Desktop.
replace(regexp/substr, replacetext) Searches and replaces the regular expression (or sub string) portion (match) with the replaced text instead.
This file contains hidden or 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(substr, replacetext) | |
var myString = '999 JavaScript Coders'; | |
console.log(myString.replace(/JavaScript/i, "jQuery")); | |
//output: 999 jQuery Coders | |
//replace(regexp, replacetext) | |
var myString = '999 JavaScript Coders'; | |
console.log(myString.replace(new RegExp( "999", "gi" ), "The")); | |
//output: The JavaScript Coders |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment