Hello,
A small greedy/non-greedy regex question for you.
I'm sure it's something simple, but I can't figure it out.
Given the following:
$echo "file.tar.gz.gpg.sig" | perl -lne 'm/(\..*?sig)/ && print $1'
.tar.gz.gpg.sig
Why does the regex match all the extensions ?
The regex requires:
\. = actual dot character
.*? = zero or more characters, non-greedy
sig = the string "sig".
I'd naively assume that "zero or more, non-greedy" should match zero characters,
and the result should be just ".sig" .
What am I doing wrong ?
Thanks,
- Assaf
_______________________________________________
Perl mailing list
[email protected]
http://mail.perl.org.il/mailman/listinfo/perl