Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re(4): Possessive Quantifiers

by Arien (Pilgrim)
on Aug 18, 2002 at 10:45 UTC ( [id://190971]=note: print w/replies, xml ) Need Help??


in reply to Re(3): Possessive Quantifiers
in thread Possessive Quantifiers

I'm guessing that (?>a*b*) is equivalent to Java's a*+b*+.

The equivalent to Java's a*+b*+ would be (?>a*)(?>b*). In this case that wouldn't make a difference of course, but it would in situations like this one:

$_ = "aaab"; print "/(?>[ab]+)(?>b+)/ matches $_\n" if /(?>[ab]+)(?>b+)/; print "/(?>[ab]+b+)/ matches $_\n" if /(?>[ab]+b+)/;
What about (?>a*(b|c)d*)? Can that be expressed in Java at all?

How about (a*(b|c)d*){1}+? (Yeah, it's ugly...)

— Arien

Replies are listed 'Best First'.
Re: Re(4): Possessive Quantifiers
by Ferret (Scribe) on Aug 18, 2002 at 17:36 UTC

    > How about (a*(b|c)d*){1}+? (Yeah, it's ugly...)

    Yup, it is. But that's why we keep the uglier but more appropriate (?>) around in Perl. Occasionally, it's the right/only operator for the job.

    As best as I can figure, java thinks it's being clever by using the possessive instead of (?>), which is dumb, since it doesn't cover the simple case of exactly one match. We can do better than that :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2025-02-09 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (95 votes). Check out past polls.