Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://731150]
help
Chatterbox?
[stevieb]: w00t! my i2c module actually works, and it works well!

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2017-06-22 22:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (531 votes). Check out past polls.