Here is one way to do it. In your coding you have used unnecessary greediness. You have to take a look at perlre
my $data = "Exlief 4 page : 1 /10"; if ($data =~ /pag[^:]*:\s*(\d+)[^\d]*(\d*)/) { print "Pages : $1 / $2\n"; } my $data = "Exlief 4 page : 1 / 5"; if ($data =~ /pag[^:]*:\s*(\d+)[^\d]*(\d*)/) { print "Pages : $1 / $2\n"; } output: Pages : 1 / 10 Pages : 1 / 5
Prasad
In reply to Re: Matching numbers by regex.
by prasadbabu
in thread Matching numbers by regex.
by Wasted
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |