develooper Front page | perl.beginners | Postings from September 2009

Regexps handle only the first number

Thread Next
From:
Mishustin Alexey
Date:
September 7, 2009 11:42
Subject:
Regexps handle only the first number
Message ID:
1252348907.5585.5.camel@localhost
Hello,

Why do these regexps handle only the first number?

$ cat ./test.pl 
#!/usr/bin/perl

use strict;
use warnings;

my $raised_num = 'Tab_10' =~ /^Tab_(.*)$/;
print $raised_num."\n";

$raised_num = 'Tab_11' =~ /^Tab_([0-9]+)$/;
print $raised_num."\n";

$raised_num = 'Tab_12' =~ /^Tab_([0-9][0-9])$/;
print $raised_num."\n";
$ ./test.pl 
1
1
1

But, according to all rules, both numbers must be handled:

10
11
12

-- 
Regards,
Alex


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About