Skip to content

Improve PCRE compatibility and compare engines with vscode-textmate - #151

Merged
ryangjchandler merged 2 commits into
3.xfrom
pcre-compat
Nov 3, 2026
Merged

ryangjchandler merged 2 commits into
3.xfrom
pcre-compat

Conversation

@ryangjchandler

Copy link
Copy Markdown
Collaborator

Closes more of the gap between the PCRE and Oniguruma engines, and changes COMPATIBILITY.md to measure both engines against vscode-textmate.

PCRE fixes

  • {n}? is an optional repeat, and quantifiers apply to whole escapes such as \x41{2}+.
  • Unbounded lookbehinds such as (?<!\.\s*) now compile, with repeats capped.
  • Subexpression calls (\g<name>) set the called group's capture, as Oniguruma does.
  • Group names with dashes compile.

Compatibility report
Phiki's Oniguruma engine turned out to be an unreliable reference: mbregex drops empty captures and numbered groups in patterns with named groups. The report now compares both engines with vscode-textmate, so the workflow also installs Node dependencies.

Engine Grammars identical Matching tokens
Oniguruma 119 of 227 92.6%
PCRE 167 of 227 95.5%

ampagent and others added 2 commits November 3, 2026 23:27
- Read {n}? as an optional repeat and keep a quantifier on a whole escape.
- Compile unbounded lookbehinds by capping their repeats.
- Set the captures of groups run by subexpression calls.
- Allow dashes in group names.

Amp-Thread-ID: https://ampcode.com/threads/T-01a1a322-a00a-762a-b40f-e129343bfd34
Co-authored-by: Ryan Chandler <ryan@ryangjchandler.co.uk>
@ryangjchandler
ryangjchandler merged commit bd3bf52 into 3.x Nov 3, 2026
4 checks passed
@ryangjchandler
ryangjchandler deleted the pcre-compat branch November 3, 2026 23:29
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.

2 participants