in reply to Re: Perl Regexp help w/ grep
in thread Perl Regexp help w/ grep

the ? keeps it from being too greedy

I'm curious, what is the purpose of including this in a simple match? Seems to me that it would only make sense if it was a capturing match or a search and replace. Not that there's anything wrong with it, it just seems a bit pointless.

Replies are listed 'Best First'.
Re^3: Perl Regexp help w/ grep
by duff (Parson) on Oct 15, 2005 at 03:52 UTC

    Perhaps it's an attempt at optimization? A greedy RE will match the entire filename from that point on and then have to back track character by character to determine if there is or isn't a match. By making the RE non-greedy, matching filenames will be found faster.