firasdib / Regex101

This repository is currently only used for issue tracking for www.regex101.com
3.2k stars 198 forks source link

PCRE or PCRE2 "\g-n" for backreference as in the specification is not recognized. #2239

Closed santropedro closed 3 months ago

santropedro commented 3 months ago

Bug Description

https://www.pcre.org/current/doc/html/pcre2syntax.html#SEC22 a line reads: "\g-n relative reference by number", note there is a DIFFERENT line quoting "\g{-n} relative reference by number", that one does work in regex101. This bug is not present on regexr, see it the regex works there, and both syntaxes are described here for pcre https://www.regular-expressions.info/backrefrel.html

Reproduction steps

This regex: (a)\g-1 doesn't match string aa

Expected Outcome

It should match. With brackets works (as in the specification asks for), try: (a)\g{-1} which matches string aa.

Browser

Chrome, Version 122.0.6261.111 (Official Build) (64-bit)

OS

Edition Windows 10 Home Single Language Version 22H2 Installed on ‎21/‎07/‎05 OS build 19045.4046 Experience Windows Feature Experience Pack 1000.19053.1000.0

firasdib commented 3 months ago

Thank you, I'll have this resolved in the next release.