22599[Clip] Re: FIND in NTL V7pr3 still acting odd
- Apr 14, 2012--- In firstname.lastname@example.org, "John Shotsky" <jshotsky@...> wrote:
> Hmmm I'm not sure I understand the argument. All I said is that
> if \s* precedes a \R, the \R would never capture anything,
> because the \s would capture any following contiguous whitespace.
> If you are saying that is not true, I can't see why it would
> not be true.
If you test '\s*\R' (NT 6.2) against
the CRNL at the end of the first and the second line are matched.
That is: We, obviously, can't say "if \s* precedes a \R, the \R would never capture anything, because the \s would capture any following contiguous whitespace".
If '\s*' (in NT 6.2) or '(\s)*' (in NT 7.0) would consume all white spaces between those lines, the RegEx engine would miss a following '\R' and fail -- but it doesn't!
The reason is in backtracking: First, '\s*' matches both CR and NL contained in CRNL. Next, the engine will test the '\R'. Since it's missing, the engine tracks back and forces '\s' to give back at least one white space. So '\R' is satisfied with the NL (since it matches both CRNL and NL) -- and the whole pattern is true.
- << Previous post in topic Next post in topic >>