Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by tybalt89 (Monsignor)
on Mar 08, 2021 at 02:25 UTC ( [id://11129307]=note: print w/replies, xml ) Need Help??


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

Because (?= and (?! are ZERO-WIDTH assertions.

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

Replies are listed 'Best First'.
Re^4: How to enforce match priority irrespective of string position
by Polyglot (Chaplain) on Mar 08, 2021 at 02:37 UTC

    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~

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-20 08:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found