andgineer / TRegExpr

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

Look behind fails when calling Exec(Offset) #302

Closed User4martin closed 1 year ago

User4martin commented 1 year ago

The following test should work.

 CompileRE('(?<=.A...)(X)');
 RE.InputString:= '_A123X3';
 IsTrue('Exec must give True', RE.Exec(2));

It does work, when called without offset.

But, with offset, it can still look back to before the offset, and therefore should find this.

The following modified version demonstrates the expectation: https://regex101.com/r/51WHvZ/1

The leading _| matches one char, the pattern is global, so it is matched a 2nd time at start-offset = 2. And the result for the 2nd match is success.

Alexey-T commented 1 year ago

No idea how to fix, yet.

User4martin commented 1 year ago

I will look later / lets concentrate on the big PR first.

User4martin commented 1 year ago

This issue can be on hold / it will be closed as side product of implementing better support for all lookaround patterns (in progress)

Alexey-T commented 1 year ago

@User4martin Is it solved? Then please close.