Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Why doens't non-greediness work?

by cciulla (Friar)
on May 10, 2003 at 12:56 UTC ( [id://257123]=note: print w/replies, xml ) Need Help??


in reply to Why doesn't non-greediness work?

Update: Seriously beaten to the punch and the above answers are WAY better than mine. :)

Because the first sub is clobbering the second sub.

Check this out...

my $body = qq!<img border="0" src="/images/wink.gif" alt="Wink"> <img +border="0" src="/images/smiley.gif" alt="Smiley">!; print "Inital Value\t $body\n"; $body =~ s/<img(.+?)="Smiley">/:)/g; print "First Sub\t $body\n"; $body =~ s/<img(.+?)="Wink">/;)/g; print "Second Sub\t $body\n";

Translating the first sub, ala Friedl:

find <img followed by one or more characters repeated zero or one times followed by ="Smiley"

So, it's being TOO greedy!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-29 02:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found