2009/11/23 Alan Haggai Alavi <alanhag...@alanhaggai.org>:
> my $number = '0000000000000111';
> my ($index) = ( $number =~ /\d+(\d{3})/ );
>
> $index would contain the last three digits: '111'.

\d+ should be \d* above, otherwise you fail to match on 3 digit numbers:

p...@tui:~/tmp$ perl -E '
my $number = q{111};
my ($index) = ( $number =~ /\d+(\d{3})/ );
say $index'

p...@tui:~/tmp$

Phil

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to