except that you don't want the /g (global) switch on the regex! Consider:
use strict; use warnings; my $str = 'wibble 10'; print "Matched $1\n" if $str =~ /(\d+)/g; print "Matched $1\n" if $str =~ /(\w+)/g;
Prints:
Matched 10
Because of the /g switch the second match fails because is starts searching from where the first match left off.
In reply to Re^2: Regex to extract number from text file
by GrandFather
in thread Regex to extract number from text file
by premal
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |