diff --git a/src/validator.ts b/src/validator.ts
index d96e8e4..8eaa757 100644
--- a/src/validator.ts
+++ b/src/validator.ts
@@ -526,19 +526,8 @@ export class RegExpValidator {
uFlag = false,
): void {
this._uFlag = uFlag && this.ecmaVersion >= 2015
- this._nFlag = uFlag && this.ecmaVersion >= 2018
this.reset(source, start, end)
this.consumePattern()
-
- if (
- !this._nFlag &&
- this.ecmaVersion >= 2018 &&
- this._groupNames.size > 0
- ) {
- this._nFlag = true
- this.rewind(start)
- this.consumePattern()
- }
}
// #region Delegate for Options
@@ -893,7 +882,11 @@ export class RegExpValidator {
*/
private consumePattern(): void {
const start = this.index
- this._numCapturingParens = this.countCapturingParens()
+ const [unnamedGroups, namedGroups] = this.countCapturingParens()
+
+ this._nFlag =
+ this.ecmaVersion >= 2018 && (this._uFlag || namedGroups > 0)
+ this._numCapturingParens = unnamedGroups + namedGroups
this._groupNames.clear()
this._backreferenceNames.clear()
@@ -924,13 +917,15 @@ export class RegExpValidator {
/**
* Count capturing groups in the current source code.
- * @returns The number of capturing groups.
+ * @returns The number of unnamed capturing groups and the number of named
+ * capturing groups.
*/
- private countCapturingParens(): number {
+ private countCapturingParens(): [number, number] {
const start = this.index
let inClass = false
let escaped = false
- let count = 0
+ let unnamedCount = 0
+ let namedCount = 0
let cp = 0
while ((cp = this.currentCodePoint) !== -1) {
@@ -942,21 +937,23 @@ export class RegExpValidator {
inClass = true
} else if (cp === RightSquareBracket) {
inClass = false
- } else if (
- cp === LeftParenthesis &&
- !inClass &&
- (this.nextCodePoint !== QuestionMark ||
- (this.nextCodePoint2 === LessThanSign &&
- this.nextCodePoint3 !== EqualsSign &&
- this.nextCodePoint3 !== ExclamationMark))
- ) {
- count += 1
+ } else if (cp === LeftParenthesis && !inClass) {
+ if (
+ this.nextCodePoint === QuestionMark &&
+ this.nextCodePoint2 === LessThanSign &&
+ this.nextCodePoint3 !== EqualsSign &&
+ this.nextCodePoint3 !== ExclamationMark
+ ) {
+ namedCount += 1
+ } else if (this.nextCodePoint !== QuestionMark) {
+ unnamedCount += 1
+ }
}
this.advance()
}
this.rewind(start)
- return count
+ return [unnamedCount, namedCount]
}
/**
diff --git a/test/fixtures/parser/literal/named-capturing-group-strict-invalid-2018.json b/test/fixtures/parser/literal/named-capturing-group-strict-invalid-2018.json
new file mode 100644
index 0000000..5c88288
--- /dev/null
+++ b/test/fixtures/parser/literal/named-capturing-group-strict-invalid-2018.json
@@ -0,0 +1,26 @@
+{
+ "options": {
+ "strict": true,
+ "ecmaVersion": 2018
+ },
+ "patterns": {
+ "/\\k/": {
+ "error": {
+ "message": "Invalid regular expression: /\\k/: Invalid escape",
+ "index": 2
+ }
+ },
+ "/\\k/": {
+ "error": {
+ "message": "Invalid regular expression: /\\k/: Invalid escape",
+ "index": 2
+ }
+ },
+ "/(?a)\\2/": {
+ "error": {
+ "message": "Invalid regular expression: /(?a)\\2/: Invalid escape",
+ "index": 10
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/test/fixtures/parser/literal/named-capturing-group-strict-valid-2018.json b/test/fixtures/parser/literal/named-capturing-group-strict-valid-2018.json
new file mode 100644
index 0000000..0d13cfa
--- /dev/null
+++ b/test/fixtures/parser/literal/named-capturing-group-strict-valid-2018.json
@@ -0,0 +1,1736 @@
+{
+ "options": {
+ "strict": true,
+ "ecmaVersion": 2018
+ },
+ "patterns": {
+ "/(a)/": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 5,
+ "raw": "/(a)/",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 4,
+ "raw": "(a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 4,
+ "raw": "(a)",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 4,
+ "raw": "(a)",
+ "name": null,
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 2,
+ "end": 3,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 2,
+ "end": 3,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": []
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 5,
+ "end": 5,
+ "raw": "",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": false,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?:a)/": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 7,
+ "raw": "/(?:a)/",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 6,
+ "raw": "(?:a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 6,
+ "raw": "(?:a)",
+ "elements": [
+ {
+ "type": "Group",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 6,
+ "raw": "(?:a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 4,
+ "end": 5,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 4,
+ "end": 5,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 7,
+ "end": 7,
+ "raw": "",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": false,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?)/": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 8,
+ "raw": "/(?)/",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 7,
+ "raw": "(?)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 7,
+ "raw": "(?)",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 7,
+ "raw": "(?)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 6,
+ "raw": "",
+ "elements": []
+ }
+ ],
+ "references": []
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 8,
+ "end": 8,
+ "raw": "",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": false,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?a)\\k/": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 14,
+ "raw": "/(?a)\\k/",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 13,
+ "raw": "(?a)\\k",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 13,
+ "raw": "(?a)\\k",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 8,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 13,
+ "raw": "\\k",
+ "ref": "a",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 14,
+ "end": 14,
+ "raw": "",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": false,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?a)\\k/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 15,
+ "raw": "/(?a)\\k/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 13,
+ "raw": "(?a)\\k",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 13,
+ "raw": "(?a)\\k",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 8,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 13,
+ "raw": "\\k",
+ "ref": "a",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 14,
+ "end": 15,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?a)\\1/": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 11,
+ "raw": "/(?a)\\1/",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 10,
+ "raw": "(?a)\\1",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 10,
+ "raw": "(?a)\\1",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 8,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 10,
+ "raw": "\\1",
+ "ref": 1,
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 11,
+ "end": 11,
+ "raw": "",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": false,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?a)\\1/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 12,
+ "raw": "/(?a)\\1/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 10,
+ "raw": "(?a)\\1",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 10,
+ "raw": "(?a)\\1",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 8,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 10,
+ "raw": "\\1",
+ "ref": 1,
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 11,
+ "end": 12,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?a)(?a)/": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 16,
+ "raw": "/(?a)(?a)/",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 15,
+ "raw": "(?a)(?a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 15,
+ "raw": "(?a)(?a)",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 8,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": []
+ },
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 15,
+ "raw": "(?a)",
+ "name": "b",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 13,
+ "end": 14,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 13,
+ "end": 14,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": []
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 16,
+ "end": 16,
+ "raw": "",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": false,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?a)(?a)/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 17,
+ "raw": "/(?a)(?a)/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 15,
+ "raw": "(?a)(?a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 15,
+ "raw": "(?a)(?a)",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 8,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": []
+ },
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 15,
+ "raw": "(?a)",
+ "name": "b",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 13,
+ "end": 14,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 13,
+ "end": 14,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": []
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 16,
+ "end": 17,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/\\k(?a)/": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 14,
+ "raw": "/\\k(?a)/",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 13,
+ "raw": "\\k(?a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 13,
+ "raw": "\\k(?a)",
+ "elements": [
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 6,
+ "raw": "\\k",
+ "ref": "a",
+ "resolved": "♻️../1"
+ },
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 13,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 11,
+ "end": 12,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 11,
+ "end": 12,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../0"
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 14,
+ "end": 14,
+ "raw": "",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": false,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/\\k(?a)/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 15,
+ "raw": "/\\k(?a)/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 13,
+ "raw": "\\k(?a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 13,
+ "raw": "\\k(?a)",
+ "elements": [
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 6,
+ "raw": "\\k",
+ "ref": "a",
+ "resolved": "♻️../1"
+ },
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 13,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 11,
+ "end": 12,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 11,
+ "end": 12,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../0"
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 14,
+ "end": 15,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/\\1(?a)/": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 11,
+ "raw": "/\\1(?a)/",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 10,
+ "raw": "\\1(?a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 10,
+ "raw": "\\1(?a)",
+ "elements": [
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 3,
+ "raw": "\\1",
+ "ref": 1,
+ "resolved": "♻️../1"
+ },
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 3,
+ "end": 10,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 9,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 9,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../0"
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 11,
+ "end": 11,
+ "raw": "",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": false,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/\\1(?a)/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 12,
+ "raw": "/\\1(?a)/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 10,
+ "raw": "\\1(?a)",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 10,
+ "raw": "\\1(?a)",
+ "elements": [
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 3,
+ "raw": "\\1",
+ "ref": 1,
+ "resolved": "♻️../1"
+ },
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 3,
+ "end": 10,
+ "raw": "(?a)",
+ "name": "a",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 9,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 9,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../0"
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 11,
+ "end": 12,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?<$abc>a)\\k<$abc>/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 21,
+ "raw": "/(?<$abc>a)\\k<$abc>/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 19,
+ "raw": "(?<$abc>a)\\k<$abc>",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 19,
+ "raw": "(?<$abc>a)\\k<$abc>",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 11,
+ "raw": "(?<$abc>a)",
+ "name": "$abc",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 9,
+ "end": 10,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 9,
+ "end": 10,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 11,
+ "end": 19,
+ "raw": "\\k<$abc>",
+ "ref": "$abc",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 20,
+ "end": 21,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?<あ>a)\\k<あ>/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 15,
+ "raw": "/(?<あ>a)\\k<あ>/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 13,
+ "raw": "(?<あ>a)\\k<あ>",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 13,
+ "raw": "(?<あ>a)\\k<あ>",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 8,
+ "raw": "(?<あ>a)",
+ "name": "あ",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 6,
+ "end": 7,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 13,
+ "raw": "\\k<あ>",
+ "ref": "あ",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 14,
+ "end": 15,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?<𠮷>a)\\k<\\u{20bb7}>/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 24,
+ "raw": "/(?<𠮷>a)\\k<\\u{20bb7}>/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 22,
+ "raw": "(?<𠮷>a)\\k<\\u{20bb7}>",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 22,
+ "raw": "(?<𠮷>a)\\k<\\u{20bb7}>",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 9,
+ "raw": "(?<𠮷>a)",
+ "name": "𠮷",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 7,
+ "end": 8,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 7,
+ "end": 8,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 9,
+ "end": 22,
+ "raw": "\\k<\\u{20bb7}>",
+ "ref": "𠮷",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 23,
+ "end": 24,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?<\\uD842\\uDFB7>a)\\k<\\u{20bb7}>/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 34,
+ "raw": "/(?<\\uD842\\uDFB7>a)\\k<\\u{20bb7}>/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 32,
+ "raw": "(?<\\uD842\\uDFB7>a)\\k<\\u{20bb7}>",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 32,
+ "raw": "(?<\\uD842\\uDFB7>a)\\k<\\u{20bb7}>",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 19,
+ "raw": "(?<\\uD842\\uDFB7>a)",
+ "name": "𠮷",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 17,
+ "end": 18,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 17,
+ "end": 18,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 19,
+ "end": 32,
+ "raw": "\\k<\\u{20bb7}>",
+ "ref": "𠮷",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 33,
+ "end": 34,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?<\\u{20bb7}>a)\\k<\\uD842\\uDFB7>/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 34,
+ "raw": "/(?<\\u{20bb7}>a)\\k<\\uD842\\uDFB7>/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 32,
+ "raw": "(?<\\u{20bb7}>a)\\k<\\uD842\\uDFB7>",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 32,
+ "raw": "(?<\\u{20bb7}>a)\\k<\\uD842\\uDFB7>",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 16,
+ "raw": "(?<\\u{20bb7}>a)",
+ "name": "𠮷",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 14,
+ "end": 15,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 14,
+ "end": 15,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 16,
+ "end": 32,
+ "raw": "\\k<\\uD842\\uDFB7>",
+ "ref": "𠮷",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 33,
+ "end": 34,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?a)\\k<\\u0061\\u0062\\u0063>/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 34,
+ "raw": "/(?a)\\k<\\u0061\\u0062\\u0063>/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 32,
+ "raw": "(?a)\\k<\\u0061\\u0062\\u0063>",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 32,
+ "raw": "(?a)\\k<\\u0061\\u0062\\u0063>",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 10,
+ "raw": "(?a)",
+ "name": "abc",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 9,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 8,
+ "end": 9,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 10,
+ "end": 32,
+ "raw": "\\k<\\u0061\\u0062\\u0063>",
+ "ref": "abc",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 33,
+ "end": 34,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?<\\u0061\\u0062\\u0063>a)\\k/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 34,
+ "raw": "/(?<\\u0061\\u0062\\u0063>a)\\k/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 32,
+ "raw": "(?<\\u0061\\u0062\\u0063>a)\\k",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 32,
+ "raw": "(?<\\u0061\\u0062\\u0063>a)\\k",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 25,
+ "raw": "(?<\\u0061\\u0062\\u0063>a)",
+ "name": "abc",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 23,
+ "end": 24,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 23,
+ "end": 24,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 25,
+ "end": 32,
+ "raw": "\\k",
+ "ref": "abc",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 33,
+ "end": 34,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?<\\u0061\\u0062\\u0063>a)\\k<\\u{61}\\u{62}\\u{63}>/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 49,
+ "raw": "/(?<\\u0061\\u0062\\u0063>a)\\k<\\u{61}\\u{62}\\u{63}>/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 47,
+ "raw": "(?<\\u0061\\u0062\\u0063>a)\\k<\\u{61}\\u{62}\\u{63}>",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 47,
+ "raw": "(?<\\u0061\\u0062\\u0063>a)\\k<\\u{61}\\u{62}\\u{63}>",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 25,
+ "raw": "(?<\\u0061\\u0062\\u0063>a)",
+ "name": "abc",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 23,
+ "end": 24,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 23,
+ "end": 24,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 25,
+ "end": 47,
+ "raw": "\\k<\\u{61}\\u{62}\\u{63}>",
+ "ref": "abc",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 48,
+ "end": 49,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ },
+ "/(?a)\\k/u": {
+ "ast": {
+ "type": "RegExpLiteral",
+ "parent": null,
+ "start": 0,
+ "end": 17,
+ "raw": "/(?a)\\k/u",
+ "pattern": {
+ "type": "Pattern",
+ "parent": "♻️..",
+ "start": 1,
+ "end": 15,
+ "raw": "(?a)\\k",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 15,
+ "raw": "(?a)\\k",
+ "elements": [
+ {
+ "type": "CapturingGroup",
+ "parent": "♻️../..",
+ "start": 1,
+ "end": 9,
+ "raw": "(?a)",
+ "name": "a1",
+ "alternatives": [
+ {
+ "type": "Alternative",
+ "parent": "♻️../..",
+ "start": 7,
+ "end": 8,
+ "raw": "a",
+ "elements": [
+ {
+ "type": "Character",
+ "parent": "♻️../..",
+ "start": 7,
+ "end": 8,
+ "raw": "a",
+ "value": 97
+ }
+ ]
+ }
+ ],
+ "references": [
+ "♻️../1"
+ ]
+ },
+ {
+ "type": "Backreference",
+ "parent": "♻️../..",
+ "start": 9,
+ "end": 15,
+ "raw": "\\k",
+ "ref": "a1",
+ "resolved": "♻️../0"
+ }
+ ]
+ }
+ ]
+ },
+ "flags": {
+ "type": "Flags",
+ "parent": "♻️..",
+ "start": 16,
+ "end": 17,
+ "raw": "u",
+ "global": false,
+ "ignoreCase": false,
+ "multiline": false,
+ "unicode": true,
+ "sticky": false,
+ "dotAll": false
+ }
+ }
+ }
+ }
+}
\ No newline at end of file