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

Replies are listed 'Best First'.
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