From d7ca3790050490f91d3398e32e5e05627cf30a5b Mon Sep 17 00:00:00 2001 From: Michael Dyck Date: Thu, 16 Sep 2021 10:10:35 -0400 Subject: [PATCH] Editorial: Change `the _index_th element of _captures_` ... 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. --- spec.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec.html b/spec.html index 25ad284fb8b..87074da4652 100644 --- a/spec.html +++ b/spec.html @@ -33375,7 +33375,7 @@

1. If _index_ = 0, then 1. Let _refReplacement_ be _ref_. 1. Else if _index_ ≤ the number of elements in _captures_, then - 1. Let _capture_ be the _index_th 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, @@ -35788,6 +35788,7 @@

RegExp.prototype [ @@replace ] ( _string_, _replaceValue_ )

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_th capture (the characters captured by the _n_th 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