Syntax
string.replace(regexpression, replacestring)
The replace() method searches the string for the regular expression passed to the method.
If a match is found, the method returns a new string with that match replaced with the replacement string passed to the method.
See the reference entry for RegExp.
<html> <script language="JavaScript1.2"> <!-- var myString = new String("This is a test"); var myRegExp = /is/g; var newString = myString.replace(myRegExp, "test"); document.write('Notice the last name in the original string, ' + myString); document.write(', was replaced and is now '+ newString); document.close(); --> </script> </html>
6.23.replace | ||||
6.23.1. | String.replace() | |||
6.23.2. | Using the replace() method of the String object |