Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Issue 2775303002: [regexp] Named capture support for string replacements (Closed)

Created:
3 years, 9 months ago by jgruber
Modified:
3 years, 9 months ago
Reviewers:
Dan Ehrenberg, Yang
CC:
v8-reviews_googlegroups.com, rmcilroy
Target Ref:
refs/heads/master
Project:
v8
Visibility:
Public.

Description

[regexp] Named capture support for string replacements This implements support for named captures in RegExp.prototype[@@replace] for when the replaceValue is not callable. Named captures can be referenced from replacement strings by using the "$<name>" syntax. A couple of examples: let re = /(?<fst>.)(?<snd>.)/u; "abcd".replace(re, "$<snd>$<fst>") // "bacd" "abcd".replace(re, "$2$1") // "bacd" (numbered refs work as always) "abcd".replace(re, "$<snd") // SyntaxError (unterminated named ref) "abcd".replace(re, "$<42$1>") // "cd" (invalid name) "abcd".replace(re, "$<thd>") // "cd" (non-existent name) "abcd".replace(/(?<fst>.)|(?<snd>.)/u, "$<snd>") // "cd" (non-matched capture) Support is currently behind the --harmony-regexp-named-captures flag. BUG=v8:5437 Review-Url: https://codereview.chromium.org/2775303002 Cr-Original-Commit-Position: refs/heads/master@{#44171} Committed: https://chromium.googlesource.com/v8/v8/+/17f13863b64b25eccf565e0aa9c4c441f0562b84 Review-Url: https://codereview.chromium.org/2775303002 Cr-Commit-Position: refs/heads/master@{#44182} Committed: https://chromium.googlesource.com/v8/v8/+/9403edfa83d0dcfdb6f110b5dc4674e4534c26e0

Patch Set 1 #

Patch Set 2 : Rebase #

Patch Set 3 : Preserve subject flattening #

Patch Set 4 : Run ToObject on non-object namedCaptures objects #

Patch Set 5 : Only cast if not undefined #

Unified diffs Side-by-side diffs Delta from patch set Stats (+362 lines, -58 lines) Patch
M src/messages.h View 1 chunk +1 line, -0 lines 0 comments Download
M src/objects.h View 1 4 chunks +13 lines, -2 lines 0 comments Download
M src/objects.cc View 1 3 chunks +42 lines, -0 lines 0 comments Download
M src/runtime/runtime-regexp.cc View 1 2 3 4 20 chunks +231 lines, -44 lines 0 comments Download
M src/runtime/runtime-strings.cc View 1 chunk +10 lines, -3 lines 0 comments Download
M test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden View 4 chunks +4 lines, -4 lines 0 comments Download
M test/cctest/interpreter/bytecode_expectations/ForOf.golden View 4 chunks +4 lines, -4 lines 0 comments Download
M test/cctest/interpreter/bytecode_expectations/Generators.golden View 1 chunk +1 line, -1 line 0 comments Download
M test/mjsunit/harmony/regexp-named-captures.js View 1 chunk +56 lines, -0 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 35 (27 generated)
jgruber
PTAL. This is the final CL for named capture support.
3 years, 9 months ago (2017-03-27 13:43:00 UTC) #8
Yang
On 2017/03/27 13:43:00, jgruber wrote: > PTAL. This is the final CL for named capture ...
3 years, 9 months ago (2017-03-28 07:01:00 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2775303002/80001
3 years, 9 months ago (2017-03-28 07:55:07 UTC) #24
commit-bot: I haz the power
Committed patchset #5 (id:80001) as https://chromium.googlesource.com/v8/v8/+/17f13863b64b25eccf565e0aa9c4c441f0562b84
3 years, 9 months ago (2017-03-28 08:02:10 UTC) #27
jgruber
A revert of this CL (patchset #5 id:80001) has been created in https://codereview.chromium.org/2776293003/ by jgruber@chromium.org. ...
3 years, 9 months ago (2017-03-28 09:02:04 UTC) #28
jgruber
On 2017/03/28 09:02:04, jgruber wrote: > A revert of this CL (patchset #5 id:80001) has ...
3 years, 9 months ago (2017-03-28 09:07:59 UTC) #30
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2775303002/80001
3 years, 9 months ago (2017-03-28 09:08:08 UTC) #32
commit-bot: I haz the power
3 years, 9 months ago (2017-03-28 09:09:49 UTC) #35
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as
https://chromium.googlesource.com/v8/v8/+/9403edfa83d0dcfdb6f110b5dc4674e4534...

Powered by Google App Engine
This is Rietveld 408576698