JavaScript String method: replace()
[this page | pdf | back links]
The replace() method (when applied to a JavaScript
string) returns
a string that repeats a specified string a specified number of times.
It
has the following syntax with the following parameters:
string.replace(searchvalue)
|
Parameter
|
Required / Optional
|
Description
|
|
searchvalue
|
Required
|
Value or regular
expression to be replaced
|
|
newvalue
|
Required
|
New value inserted
instead
|
If searchvalue is
a normal string then only the first occurrence is replaced, if it occurs more
than once in the string being searched. If you want to replace all occurrences
then you need to use a corresponding regular expression with a /g, i.e. global, modifier.
NAVIGATION LINKS
Contents | Prev | Next | JavaScript String Variables