Skip to content

Commit

Permalink
Editorial: Change the _index_<sup>th</sup> element of _captures_ (#…
Browse files Browse the repository at this point in the history
…2484)

... to `_captures_[_index_ - 1]` in `GetSubstitution`.

Also, in `RegExp.prototype [ @@replace ]`
(the only place that passes a non-empty `_captures_` to `GetSubstitution`),
add a NOTE to underline the fact that
`_captures_[_n_ - 1]` is the `_n_`th capture.
  • Loading branch information
jmdyck authored and ljharb committed Dec 7, 2021
1 parent 99c0311 commit f2671ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -33911,7 +33911,7 @@ <h1>
1. If _index_ = 0, then
1. Let _refReplacement_ be _ref_.
1. Else if _index_ &le; the number of elements in _captures_, then
1. Let _capture_ be the _index_<sup>th</sup> element of _captures_.
1. Let _capture_ be _captures_[_index_ - 1].
1. If _capture_ is *undefined*, then
1. Let _refReplacement_ be the empty String.
1. Else,
Expand Down Expand Up @@ -36324,6 +36324,7 @@ <h1>RegExp.prototype [ @@replace ] ( _string_, _replaceValue_ )</h1>
1. If _capN_ is not *undefined*, then
1. Set _capN_ to ? ToString(_capN_).
1. Append _capN_ as the last element of _captures_.
1. NOTE: When _n_ = 1, the preceding step puts the first element into _captures_ (at index 0). More generally, the _n_<sup>th</sup> capture (the characters captured by the _n_<sup>th</sup> set of capturing parentheses) is at _captures_[_n_ - 1].
1. Set _n_ to _n_ + 1.
1. Let _namedCaptures_ be ? Get(_result_, *"groups"*).
1. If _functionalReplace_ is *true*, then
Expand Down

0 comments on commit f2671ca

Please sign in to comment.