Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Regex a little less greedy please

by arturo (Vicar)
on Mar 18, 2003 at 14:29 UTC ( [id://243988]=note: print w/replies, xml ) Need Help??


in reply to Regex a little less greedy please

From perlre :

If you want it to match the minimum 
number of times possible, follow the 
quantifier with a "?".  Note that the 
meanings don’t change, just the 
"greediness"

So, changing your regex to

<APPEND.*?>
Should get you the behavior you want. If, however, you take to heart the lessons of Death to Dot Star!, you might want to write that this way:
<APPEND[^>]*>
Avoiding using the post-match variable and using () to capture the stuff you want to get is left as an exercise for the reader =)

HTH

If not P, what? Q maybe?
"Sidney Morgenbesser"

Log In?
Username:
Password:

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

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

    No recent polls found