Standard built-ins
String.prototype.replace()
Returns replaced text; a literal search changes at most its first match. Global ordinary regexes replace multiple matches. Callback results are inserted without dollar-substitution expansion.
Formal Syntax & Structure
javascript syntaxjavascript
text.replace(searchValue, replaceValue)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| searchValue | String | RegExp | Literal or pattern to match. |
| replaceValue | String | Function | Substitution string or callback returning replacement text. |
Return Value
String
Updated text; original unchanged.
Working Example
Example Snippetjavascript
console.log("aaa".replace("a","b"));