2009/11/23 Alan Haggai Alavi <[email protected]>: > 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: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/
