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

Re: [Clip] Re: A little help on look behinds

Expand Messages
  • Sheri
    Flo, do you remember the G? I think (*COMMIT) is like that, except the match position within the subject is established dynamically after matching what s
    Message 1 of 21 , Oct 17, 2011
    • 0 Attachment
      Flo, do you remember the \G? I think (*COMMIT) is like that, except the
      match position within the subject is established dynamically after
      matching what's before the (*COMMIT).

      Remember that PCRE does not itself find multiple matches. NoteTab's
      functions and commands that find or replace multiple matches require
      NoteTab to execute PCRE multiple times at different starting positions.
      NoteTab's general behavior in doing so is to advance the cursor after a
      successful match (to find more matches past that match). NoteTab only
      advances the cursor and continues looking for more matches after a
      successful match, it doesn't do it after a "No Match" result.

      I believe \A matches only at the very start of a subject. Don't have
      time to play with GetDocListAll til later, but I think the only way more
      than one match could be found using a pattern starting with \A would be
      if NoteTab were sending PCRE different subject strings on each execution
      (not just different starting positions). Would surprise me if it is.

      Regards,
      Sheri
    • flo.gehrke
      ... John, No surprise -- I took your message literally. In #22150, you spoke of one instance where ]]] is NOT preceded anywhere in the file by a [[[. That is
      Message 2 of 21 , Oct 17, 2011
      • 0 Attachment
        --- In ntb-clips@yahoogroups.com, "John Shotsky" <jshotsky@...> wrote:
        >
        > Flo,
        >
        > It turns out that your suggestion fails at times, and takes out ]]]
        > which IS preceded by a [[[ somewhere above it in the
        > text....

        John,

        No surprise -- I took your message literally. In #22150, you spoke of "one instance where ]]] is NOT preceded anywhere in the file by a [[[. That is the only ]]] that should be removed. It is always the first one."

        Well, here's another idea: It removes any line (empty or not) starting with ']]]' which is NOT preceeded by '[[['. All lines starting with '[[[' and being followed somewhere by a closing ']]]' are left untouched.

        ^!Replace "(?s)^\[{3}.*?\]{3}\K|(?-s)^\]{3}.*(\R{1,}|\Z)" >> "" WARS

        Tested with...

        Beginning of file
        [This text is to remain]
        ]]]
        ]]] remove
        [[[ valid line
        valid line ]]]
        [[[ valid line ]]]
        [[[
        valid line
        ]]]
        ]]] remove

        Line #3, #4, and #11 will be removed.

        Regards,
        Flo
      • flo.gehrke
        ... Oh yes, I do remember G ! Great discussion in Oct 2008 (see #18566) Probably, this could explain why, at times, they call (*COMMIT) an anchor. Thanks
        Message 3 of 21 , Oct 17, 2011
        • 0 Attachment
          --- In ntb-clips@yahoogroups.com, Sheri <silvermoonwoman@...> wrote:
          >
          > Flo, do you remember the \G? I think (*COMMIT) is like that,...

          Oh yes, I do remember '\G'! Great discussion in Oct 2008 (see #18566)

          Probably, this could explain why, at times, they call '(*COMMIT)' an anchor.

          Thanks again for your explanations. It's always a pleasure to learn more about NT's hidden secrets from you :-)

          Flo
        Your message has been successfully submitted and would be delivered to recipients shortly.