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

Re: [Clip] Re: Search and Replace and increment number at the same time

Expand Messages
  • Sheri
    ... PCRE seeks backward from its bump-along starting point for a look-behind assertion. The fixed length requirement will never change; however it is
    Message 1 of 9 , Oct 11, 2009
    • 0 Attachment
      Alec Burgess wrote:
      > flo.gehrke (flo.gehrke@...) wrote (in part) (on 2009-10-11 at
      > 19:05):
      >
      >> --- In ntb-clips@yahoogroups.com, Alec Burgess <buralex@...> wrote:
      >>
      >> > I've seen you (Sheri) and Flo use the \K construct before w/o
      >> > ever really understanding exactly how it worked.
      >> > Now that I know what the \K does, is there any difference between
      >> the
      >> > two (other than the simplicity of \K)
      >>
      >> Alec,
      >>
      >> As you you wrote, \K is similar to a Lookbehind Assertion. So
      >> (?<=Look)behind matches 'Lookbehind' without consuming the 'Look'.
      >> Look\Kbehind has the same effect.
      >>
      >> The difference is that the Lookbehind demands a fixed lenghth of the
      >> pattern whereas \K works with any length. That's why I often prefer
      >> \K.
      >>
      >> For example: (?<=\w+)behind produces an Error Message "Regex error:
      >> lookbehind assertion is not of fixed length." In contrast to that,
      >> \w+\Kbehind works fine.
      >>
      >
      > Fixed length limitations in lookbehinds rang a bell when you mentioned
      > it. When I check with RegexBuddy I see that it fails with its (somewhat
      > old implementation of PCRE) but works with the JGSoft flavor (ie. Jan's
      > "superset" version of ALL regex flavors) and also with .NET flavor but
      > fails in most of the rest. For those that fail its indicated by marking
      > the "+" in RED.
      >
      > I'm not sure if any future version of PCRE (and hence when supported by
      > Eric) Notetab will support this. I'll try to remember the key
      > distinction wrt. to \K when I write clips. Thanks for the followup info
      > (and Don for the question!).
      > //
      >
      >
      PCRE seeks backward from its "bump-along" starting point for a
      look-behind assertion.

      The fixed length requirement will never change; however it is
      permissible to have alternates of varying lengths within a look-behind.

      In order to achieve the same match using \K instead of a look-behind
      assertion, the bump-along position is at the beginning of the would-be
      look-behind. So while the results are similar, the processing differs.

      Regards,
      Sheri
    Your message has been successfully submitted and would be delivered to recipients shortly.