Skip to content
Merged
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions src/xregexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const nativeTokens = {
'class': /\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/
};
// Any backreference or dollar-prefixed character in replacement strings
const replacementToken = /\$(?:{([\w$]+)}|<([\w$]+)>|(\d\d?|[\s\S]))/g;
const replacementToken = /\$(?:\{([\p{ID_Start}$_][\p{ID_Continue}$_\u200C\u200D]*)\}|<([\p{ID_Start}$_][\p{ID_Continue}$_\u200C\u200D]*)>|(\d\d?|[\s\S]))/gu;
// Check for correct `exec` handling of nonparticipating capturing groups
const correctExecNpcg = nativ.exec.call(/()??/, '')[1] === undefined;
// Check for ES6 `flags` prop support
Expand Down Expand Up @@ -1792,7 +1792,7 @@ XRegExp.addToken(
* and $ only. Also allows numbered backreferences as `\k<n>`.
*/
XRegExp.addToken(
/\\k<([\w$]+)>/,
/\\k<([\p{ID_Start}$_][\p{ID_Continue}$_\u200C\u200D]*)>/u,
function(match) {
// Groups with the same name is an error, else would need `lastIndexOf`
const index = isNaN(match[1]) ? (this.captureNames.indexOf(match[1]) + 1) : +match[1];
Expand Down Expand Up @@ -1844,7 +1844,7 @@ XRegExp.addToken(
* Python-style named capture as octals.
*/
XRegExp.addToken(
/\(\?P?<([\w$]+)>/,
/\(\?P?<([\p{ID_Start}$_][\p{ID_Continue}$_\u200C\u200D]*)>/u,
function(match) {
// Disallow bare integers as names because named backreferences are added to match arrays
// and therefore numeric properties may lead to incorrect lookups
Expand Down