[Israel.pm] regex questions

Offer Kaye offer.kaye at gmail.com
Mon Jul 19 07:45:48 PDT 2004

On Mon, 19 Jul 2004 16:34:34 +0300, yossi.itzkovich wrote:
> Thanks,
> I still have to check if it good for me, but since
> (Nav)?
> matches empty string, then
> (.*?)
> can "eat" everything untill the end (including any "Nav").
> Correct ?

Wrong - ".*?" is non-greedy, so it *won't* match everything to the end
including the Nav - that is why this solution works. You did state
that you don't want the Nav in $1, right?
> m{\[DB(.*?)(Nav)?\]}

You've changed my solution, which is okay, as long as you know what
you're doing... changing the "*" at the end to "?" is okay, since it
means "zero or one" instead of "zero or more". However, removing the
"?:" before the Nav is not so good- it causes the grouping to be
assigned to $2, which you're not doing anything with and don't even
want. So why did you remove it?

Offer Kaye

More information about the Perl mailing list