Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Can you do "conjunctive" (overlapping) conditions in a single regexp?

by puterboy (Scribe)
on Dec 18, 2008 at 03:46 UTC ( [id://731150]=note: print w/replies, xml ) Need Help??


in reply to Re: Can you do "conjunctive" (overlapping) conditions in a single regexp?
in thread Can you do "conjunctive" (overlapping) conditions in a single regexp?

Thanks & very clever (probably too clever for my little brain ;)- I'm trying though to see whether I can use case #1, rather than your much hairier second example.

I actually want to preserve the field and keep it with the split, so prior to adding the length limitation, I was using:

split /(?=$regex)/, $string
And I want to get only the greediest match (that satisfies the length condition). So, does that mean I can't use first alternative then?
  • Comment on Re^2: Can you do "conjunctive" (overlapping) conditions in a single regexp?
  • Download Code

Replies are listed 'Best First'.
Re^3: Can you do "conjunctive" (overlapping) conditions in a single regexp?
by tilly (Archbishop) on Dec 18, 2008 at 04:55 UTC
    You can't use the first version.

    You can use the second version like you did before. Just put the (?=) around the whole thing and insert whatever you want for the pattern in the middle.

    It is ugly but conceptually is not that bad. The first code pattern stores the position of the start of the match in $^R. The second one looks at the current position and the start (which is in $^R) and decides whether or not to make the match fail by interpolating in something that can't match. There are some complication around the logic, but that doesn't need to change.

      Thanks so much for the help & explanation!!!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2024-04-20 04:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found