use strict;
my $str = '10,000
10,001
10,100
100,000
999,999
149,999,999
150,000,000
55,555
99,999
73,129
834,101
1,333,333
149,000,000
20,111,000
99,001,000
10,001,000
10,999,999
2,999,999
950,000
999,999
910,000
949,999
950,000
949,999,999
1,999,999,999
100,949,999,999
1
1,0
9,000
9,999
5,555
250,000,000
9,999
100000
150,000,001
150,000,100
150,001,000
150,100,000
151,000,000
9,150,000,000
160,000,000
000,000,000
';
my $regex = qr/(?<!\S)(?:[1-9]\d\d?,\d{3}|(?:[1-9]\d?|1[0-4]\d),\d{3},\d{3}|150,000,000)(?!\S)/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html