From b7bb814dbe5f24be93d7a92e9dbc88b470b772d0 Mon Sep 17 00:00:00 2001 From: Alexey Date: Tue, 28 May 2024 13:19:23 +0300 Subject: [PATCH] another fix for back-search --- src/regexpr.pas | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/regexpr.pas b/src/regexpr.pas index 5ebcbf5d..4a8ca136 100644 --- a/src/regexpr.pas +++ b/src/regexpr.pas @@ -6870,12 +6870,12 @@ function TRegExpr.ExecPrimProtected(AOffset: Integer; ASlowChecks, if (TempMatchPos + TempMatchLen - 1 > AOffset) then Continue; - // do we have surrounding match at prev pos for regex 'w+'? take it. + // if we have surrounding match at prev pos e.g. for regex '\w+', take it PtrPrev := Ptr; repeat if (PtrPrev = fInputStart) then Break; Dec(PtrPrev); - if MatchAtOnePos(PtrPrev) and (MatchPos[0] + MatchLen[0] = TempMatchPos + TempMatchLen) then + if MatchAtOnePos(PtrPrev) and (MatchPos[0] + MatchLen[0] >= TempMatchPos + TempMatchLen) then Ptr := PtrPrev else begin