"$", or "_", or the "$", or "_", or the \ The abstract operation BackreferenceMatcher takes one argument, an integer n, and performs the following steps:
The production
When the abstract operation RegExpInitialize with arguments obj, pattern, and flags is called, the following steps are taken:
"g", "i", "m", "u", or "y" or if it contains the same code unit more than once, throw a "u", let BMP be "lastIndex", 0, The abstract operation RegExpBuiltinExec with arguments R and S performs the following steps:
"g", let global be "y", let sticky be "lastIndex"))."u", let fullUnicode be "lastIndex", 0, "lastIndex", 0, "lastIndex", e, "length" property is n + 1."index", matchIndex)."input", S)."0", matchedSubstr)."groups", groups).When the replace method is called with arguments searchValue and replaceValue, the following steps are taken:
The replace function is intentionally generic; it does not require that its
The abstract operation GetSubstitution performs the following steps:
$ replacements are done left-to-right, and, once such a replacement is performed, the new replacement text is not subject to further replacements.| Code units | Unicode Characters | Replacement text |
|---|---|---|
| 0x0024, 0x0024 |
$$
|
$
|
| 0x0024, 0x0026 |
$&
|
matched |
| 0x0024, 0x0060 |
$`
|
If position is 0, the replacement is the empty String. Otherwise the replacement is the substring of str that starts at index 0 and whose last code unit is at index position - 1. |
| 0x0024, 0x0027 |
$'
|
If tailPos ≥ stringLength, the replacement is the empty String. Otherwise the replacement is the substring of str that starts at index tailPos and continues to the end of str. |
|
0x0024, N
Where 0x0031 ≤ N ≤ 0x0039 |
$n where
n is one of 1 2 3 4 5 6 7 8 9 and $n is not followed by a decimal digit
|
The nth element of captures, where n is a single digit in the range 1 to 9. If n≤m and the nth element of captures is |
|
0x0024, N, N
Where 0x0030 ≤ N ≤ 0x0039 |
$nn where
n is one of 0 1 2 3 4 5 6 7 8 9
|
The nnth element of captures, where nn is a two-digit decimal number in the range 01 to 99. If nn≤m and the nnth element of captures is |
| 0x0024, 0x003C |
$<
|
|
| 0x0024 |
$ in any context that does not match any of the above.
|
$
|
When the @@replace method is called with arguments string and replaceValue, the following steps are taken:
"global"))."length"))."0"))."index"))."groups").The value of the name property of this function is "[Symbol.replace]".
The syntax of
This alternative pattern grammar and semantics only changes the syntax and semantics of BMP patterns. The following grammar extensions include productions parameterized with the [U] parameter. However, none of these extensions change the syntax of Unicode patterns recognized when parsing with the [U] parameter present on the
When the same left hand sides occurs with both [+U] and [~U] guards it is to control the disambiguation priority.