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

22157RE: [Clip] A little help on look behinds

Expand Messages
  • John Shotsky
    Oct 16 6:04 AM
      I found some fairly extensive explanations and examples of this and other such verbs in the PCRE text manual. Search for
      commit to find all the bits.


      From: ntb-clips@yahoogroups.com [mailto:ntb-clips@yahoogroups.com] On Behalf Of flo.gehrke
      Sent: Sunday, October 16, 2011 05:33
      To: ntb-clips@yahoogroups.com
      Subject: Re: [Clip] A little help on look behinds

      --- In ntb-clips@yahoogroups.com <mailto:ntb-clips%40yahoogroups.com> , Sheri <silvermoonwoman@...> wrote:
      > (*COMMIT) says the rest of the pattern must match from here without
      > backtracking...I guess you could say it creates an anchor in
      > the middle of the pattern.


      I would be grateful for some more explanations about that verb '(*COMMIT).

      I've tested your clip...


      against the following text which is quite similar to John's first sample. For our discussion, I've added line numbers
      (to be removed when testing):

      1 First line
      3 [valid line]
      5 ]]] remove
      7 ]]] remove
      9 [[[ valid line
      10 more valid lines
      11 ]]] valid line.
      13 [[[ valid line

      It's quite clear for me why the clip removes line #5 and #7 but not #9. But I still can't see why it doesn't remove line

      If we omit the '\K' we can see two matches:

      - 1. from start of string to end of line #5

      - 2. line #6 till end of line #7

      Next, line #8 and #9 are not matched because line #9 doesn't start with ']]]'.

      But WHY doesn't the clip jump over that mismatch and moves on selecting line #10 and #11? IMHO, line #10 should be
      matched with '(?s)\A.+?\R\K(?=\]\]\]|\[\[\[)' (with or without '\A'), and the following '(?-s)\]\]\].*\R'. Why on earth
      is '(*COMMIT)' preventing this?

      Thanks for any light you can shed on this!


      [Non-text portions of this message have been removed]
    • Show all 21 messages in this topic