andgineer / TRegExpr

Regular expressions (regex), pascal.
https://regex.sorokin.engineer/en/latest/
MIT License
174 stars 63 forks source link

Find-replace with subroutine calls: wrong value substituted #274

Closed CaptainFlint closed 2 years ago

CaptainFlint commented 2 years ago

It might be related to the issue #273 , but since I'm not sure, I'll post it separately.

Example: Original string: abc_def Search expression: ^([a-z]+)_(?1) Replace expression: $1

This expression unfolds into ^([a-z]+)_([a-z]+) ; no matter how you treat the context (whether it's global, or local), the first sub-expression matches abc. Therefore, the $1 replace expression should produce abc. But instead, it returns def.

I have checked it in Perl, and there it returns abc there.

The test TRegExpr application is: Total Commander 10.00 and 10.50 beta 5; it uses TRegExpr version: REVersionMajor = 1, REVersionMinor = 155.

CudaText-addons commented 2 years ago

fixed in my fork https://github.com/Alexey-T/TRegExpr . It affects your 2nd issue with (?R), but it needs more fixing yet.

CaptainFlint commented 2 years ago

Confirm that the fix works fine in TC 10.50b8.