Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Puzzled by regex

by syphilis (Canon)
on Apr 10, 2013 at 07:17 UTC ( #1027910=note: print w/ replies, xml ) Need Help??


in reply to Re: Puzzled by regex
in thread Puzzled by regex

Yes, but you forgot to put the trailing \n into the two regexes :-)
If I put it in, that makes the last one match as well:

Non-Greedy -- Match: ((____)). Greedy -- Match: [[____]].
Thanks for the replies guys.
I'm about to mess with that code, but I was loathe to do that while I couldn't see why the ? had been included in the regex. I still don't see why it's there - but at least now I'm starting to feel a little confident that it serves no purpose. (I'll still probably leave it there ... because I'm feeling even more confident that it doesn't do any harm :-)

Cheers,
Rob


Comment on Re^2: Puzzled by regex
Select or Download Code
Re^3: Puzzled by regex
by Anonymous Monk on Apr 10, 2013 at 07:36 UTC

    but at least now I'm starting to feel a little confident that it serves no purpose. (I'll still probably leave it there ... because I'm feeling even more confident that it doesn't do any harm :-)

    Its probably a reflex :) I know when I write regex I make more mistakes from greedines than from non-greediness, so I tend to write +? *? to be on the safe side

    I know I'm not alone in getting bit by it , it is a frequent cause/solution from newbies

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-08-20 23:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (125 votes), past polls