Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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]
[ambrus]: The keyboard I bought doesn't have backlighting. I specifically had to select for that, because so many keyboards these days have lights. Why would I want lights in the keyboard? I want lights in the room, such as on the ceiling, not in the keyboard.
choroba has a small USB lamp
[ww]: ++ all (phony labels re "gaming"
[1nickt]: ambrus perhaps you know where the keys are?
[ww]: OTOH, -- for ads suggesting that being good at games is somehow eq "greatness"

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (14)
As of 2017-03-27 13:53 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (320 votes). Check out past polls.