@@ -41,9 +41,11 @@ export function atomicGroupsPostprocessor(pattern) {
41
41
} else if ( m === ')' && inAG ) {
42
42
if ( ! numGroupsOpenInAG ) {
43
43
aGCount ++ ;
44
- // Replace pattern and use `\k<…>` as a temporary shield for the backref since numbered
45
- // backrefs are prevented separately
46
- pattern = `${ pattern . slice ( 0 , aGPos ) } ${ emulatedAGDelim } ${ pattern . slice ( aGPos + aGDelim . length , pos ) } ))\\k<${ aGCount + capturingGroupCount } >)${ pattern . slice ( pos + 1 ) } ` ;
44
+ // Replace pattern and use `\k<$$N>` as a temporary shield for the backref since
45
+ // numbered backrefs are prevented separately
46
+ pattern = `${ pattern . slice ( 0 , aGPos ) } ${ emulatedAGDelim } ${
47
+ pattern . slice ( aGPos + aGDelim . length , pos )
48
+ } ))\\k<$$${ aGCount + capturingGroupCount } >)${ pattern . slice ( pos + 1 ) } `;
47
49
hasProcessedAG = true ;
48
50
break ;
49
51
}
@@ -62,10 +64,10 @@ export function atomicGroupsPostprocessor(pattern) {
62
64
// Start over from the beginning of the last atomic group's contents, in case the processed group
63
65
// contains additional atomic groups
64
66
} while ( hasProcessedAG ) ;
65
- // Replace `\k<… >` added as a shield from the check for invalid numbered backrefs
67
+ // Replace `\k<$$N >` added as a shield from the check for invalid numbered backrefs
66
68
pattern = replaceUnescaped (
67
69
pattern ,
68
- String . raw `\\k<(?<backrefNum>\d+)>` ,
70
+ String . raw `\\k<\$\$ (?<backrefNum>\d+)>` ,
69
71
( { groups : { backrefNum} } ) => `\\${ backrefNum } ` ,
70
72
Context . DEFAULT
71
73
) ;
0 commit comments