From http://www.w3schools.com (Copyright Refsnes Data)
JavaScript String Object
The replace() method finds a match between a substring (or regular expression) and a string, and replaces the matched substring with a new substring.
| stringObject.replace(regexp/substr,newstring) |
| Parameter | Description |
|---|---|
| regexp/substr | Required. A substring or a regular expression object. Read more about the RegExp object |
| newstring | Required. The string to replace the found value in parameter 1 |
Example 1Perform a case-sensitive search:
The output of the code above will be:
Try it yourself » |
Example 2Perform a case-insensitive search:
The output of the code above will be:
Try it yourself » |
Example 3Perform a global, case-insensitive search (the word Microsoft will be replaced each time it is found):
The output of the code above will be:
Try it yourself » |
JavaScript String Object
From http://www.w3schools.com (Copyright Refsnes Data)