Loading ...
Sorry, an error occurred while loading the content.

22599[Clip] Re: FIND in NTL V7pr3 still acting odd

Expand Messages
  • flo.gehrke
    Apr 14, 2012
      --- In ntb-clips@yahoogroups.com, "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.

      John,

      If you test '\s*\R' (NT 6.2) against

      xxx
      yyy
      zzz

      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.

      Regards,
      Flo
    • Show all 15 messages in this topic