Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: regexp not greedy

by thedoe (Monk)
on Dec 13, 2005 at 20:37 UTC ( [id://516422]=note: print w/replies, xml ) Need Help??


in reply to regexp not greedy

The ? in this context, .*?, will find every character up to the first occurrence of the next portion of the match. Leaving the ? out, .*, will suck up every character to the last occurrence of the next match.

This means your regex is finding the first * after a space, the *nadie, then looking from there until it finds *loc. This is why your regex is including that entire portion of the string.

To fix this for your scenario, the regex: \s\*([^\*]*)\*loc should work fine. This matches a space, followed by a *, then any number of characters that are NOT a *, followed by a *loc.

Buena Suerte!

Replies are listed 'Best First'.
Re^2: regexp not greedy
by ivosan (Initiate) on Dec 13, 2005 at 20:44 UTC
    Dear Monk, Thank you so much, it fixed.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 02:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found