in reply to Re: question about the star(*) quantifier
in thread question about the star(*) quantifier
Since Perl is stopping at the first successful match, you'll only get the first number. Since the empty string is a successful match for \d*, that's what you're getting :)my $sentence = "I fear that i will be extinct after 1000 or 2000 years +"; if($sentence =~ /(\d+)/) { print "That said '$1' years.\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: question about the star(*) quantifier
by samtregar (Abbot) on Dec 21, 2006 at 17:42 UTC |