Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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

by puterboy (Scribe)
on Dec 18, 2008 at 03:46 UTC ( #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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://731150]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2018-06-19 03:53 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.