Skip to content

Commit d5b5e58

Browse files
committed
feat(regex-parser): support non-capturing groups
1 parent 14d330b commit d5b5e58

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/regex-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const charSet = P.choice([
102102
])
103103

104104
const group = P.between(
105-
P.string('('),
105+
P.string('(').andThen(() => P.optional(P.string('?:'))),
106106
P.string(')'),
107107
regex(),
108108
)

test/regex-parser.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ describe('parseRegexString', () => {
3131
[/^\.$/, RE.literal(CharSet.singleton('.'))],
3232
[/^[a-z]$/, RE.literal(CharSet.charRange('a', 'z'))],
3333
[/^[^abc]$/, RE.literal(CharSet.complement(CharSet.fromArray(['a', 'b', 'c'])))],
34+
[/^(?:ab)$/, RE.string('ab')], // non-capturing groups
3435
])('can parse %s', (regexp, expected) => {
3536
expect(parseRegExp(regexp)).toEqual(expected)
3637
})

0 commit comments

Comments
 (0)