colorer / Colorer-schemes

Syntax and color schemes for colorer library
31 stars 25 forks source link

regex.hrc/pcre.base: support named capture groups and backreferences #130

Closed nightroman closed 2 years ago

nightroman commented 2 years ago

PCRE specs:

According to the specs, at least these two forms are supported:

(?<name>bar) \k<name>
(?'name'bar) \k'name'

Currently, the scheme does not recognise named capture groups and treats named backreferences as syntax errors.

https://regex101.com/ shows that both forms are valid in PCRE2 (PHP >= 7.3.) and PCRE (PHP <7.3).

The commit adds these two forms support to the schema pcre.base.

The region SpecOperator is chosen to match regions of backreferences (\1, etc.).

Colorer results before and after the change (with visual.hrd and powershell scheme with inherited regex scheme):

form 1 <name> image

form 2 'name' image