Skip to content

Group quantized literals in regex optimization#55

Merged
goodmami merged 3 commits intomainfrom
gh-54-optional-literal
Jun 18, 2025
Merged

Group quantized literals in regex optimization#55
goodmami merged 3 commits intomainfrom
gh-54-optional-literal

Conversation

@goodmami
Copy link
Copy Markdown
Owner

The regex optimizer did not put a non-capturing group around quantized dots, character classes, or literals, but for literals of length > 2, this meant that only the final character was quantized:

Before:

  • 'ab'? -> `ab?`
  • 'cd'* -> `cd*`

Now:

  • 'ab?' -> `(?:ab)?`
  • 'cd'* -> `(?:cd)*`

Fixes #54

goodmami added 3 commits June 18, 2025 11:22
The regex optimizer did not put a non-capturing group around quantized
dots, character classes, or literals, but for literals of length > 2,
this meant that only the final character was quantized:

Before:
- 'ab'? -> `ab?`
- 'cd'* -> `cd*`

Now:
- 'ab?' -> `(?:ab)?`
- 'cd'* -> `(?:cd)*`

Fixes #54
@goodmami goodmami merged commit cdc9df7 into main Jun 18, 2025
6 checks passed
@goodmami goodmami deleted the gh-54-optional-literal branch June 18, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

optional literal error

1 participant