Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normative: Update GetSubstitution to match reality #3157

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -34929,11 +34929,16 @@ <h1>
1. NOTE: _tailPos_ can exceed _stringLength_ only if this abstract operation was invoked by a call to the intrinsic @@replace method of %RegExp.prototype% on an object whose *"exec"* property is not the intrinsic %RegExp.prototype.exec%.
1. Else if _templateRemainder_ starts with *"$"* followed by 1 or more decimal digits, then
1. If _templateRemainder_ starts with *"$"* followed by 2 or more decimal digits, let _digitCount_ be 2. Otherwise, let _digitCount_ be 1.
1. Let _ref_ be the substring of _templateRemainder_ from 0 to 1 + _digitCount_.
1. Let _digits_ be the substring of _templateRemainder_ from 1 to 1 + _digitCount_.
1. Let _index_ be ℝ(StringToNumber(_digits_)).
1. Assert: 0 ≤ _index_ ≤ 99.
1. Let _captureLen_ be the number of elements in _captures_.
1. If _index_ > _captureLen_ and _digitCount_ = 2, then
1. NOTE: When a two-digit replacement pattern specifies an index exceeding the count of capturing groups, it is treated as a one-digit replacement pattern followed by a literal digit.
1. Set _digitCount_ to 1.
1. Set _digits_ to the substring of _digits_ from 0 to 1.
1. Set _index_ to ℝ(StringToNumber(_digits_)).
1. Let _ref_ be the substring of _templateRemainder_ from 0 to 1 + _digitCount_.
1. If 1 ≤ _index_ ≤ _captureLen_, then
1. Let _capture_ be _captures_[_index_ - 1].
1. If _capture_ is *undefined*, then
Expand Down