2017-04-27 18:50:59 +02:00
|
|
|
// Copyright 2017 the V8 project authors. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
|
|
|
/*---
|
2018-03-06 20:31:13 +01:00
|
|
|
description: >
|
|
|
|
A missing > following $< means that the $< is taken literally
|
2017-10-13 20:16:16 +02:00
|
|
|
in a replacement string in the context of named capture substitution.
|
2017-04-27 18:50:59 +02:00
|
|
|
esid: sec-getsubstitution
|
|
|
|
features: [regexp-named-groups]
|
|
|
|
---*/
|
|
|
|
|
|
|
|
let source = "(?<fst>.)(?<snd>.)|(?<thd>x)";
|
2017-10-13 20:16:16 +02:00
|
|
|
for (let flags of ["", "u"]) {
|
|
|
|
let re = new RegExp(source, flags);
|
|
|
|
assert.sameValue("$<sndcd", "abcd".replace(re, "$<snd"));
|
|
|
|
}
|
|
|
|
for (let flags of ["g", "gu"]) {
|
2017-04-27 18:50:59 +02:00
|
|
|
let re = new RegExp(source, flags);
|
2017-10-13 20:16:16 +02:00
|
|
|
assert.sameValue("$<snd$<snd", "abcd".replace(re, "$<snd"));
|
2017-04-27 18:50:59 +02:00
|
|
|
}
|