in reply to Re^3: How to enforce match priority irrespective of string position
in thread How to enforce match priority irrespective of string position

I appreciate knowing that, but while the assertion may be "zero-width," my mind still stumbles on the point that "Point" is certainly not zero-width. I'd always understood the "zero-width" aspect to be more related to the capturing and positioning of the match within the string. Are all look-arounds zero-width? If so, why must a look-behind be always of a specified length (width) that is not variable?

Well, it may be that it's just too abstract for me.

Thank you for your explanation.

Blessings,

~Polyglot~

  • Comment on Re^4: How to enforce match priority irrespective of string position

Replies are listed 'Best First'.
Re^5: How to enforce match priority irrespective of string position
by eyepopslikeamosquito (Archbishop) on Mar 08, 2021 at 03:30 UTC

    This reference explains it quite well:

    lookaround actually matches characters, but then gives up the match, returning only the result: match or no match. That is why they are called “assertions”. They do not consume characters in the string, but only assert whether a match is possible or not.

    ... most regex flavors do not allow you to use just any regex inside a lookbehind, because they cannot apply a regular expression backwards. The regular expression engine needs to be able to figure out how many characters to step back before checking the lookbehind.

    Hope that helps.