use strict;
my $str = '1546
4 8 6 2 6 4 1 1 5 3 6 6 6 7 7 1
5378 2052 1163 1153
6011-7614 4775 1364
333 112,55 mdsksajfk
05536080
214
12/05
12/08
122sss 222222222222111 22464 222 222ss, 222,22 22.22 333215122 22 33 123456789012
122.44
445
1546
4 8 6 2 6 4 1 1 5 3 6 6 6 7 7 1
5378 2052 1163 1153
6011-7614 4775 1364
333 112,55 mdsksajfk
11947285580
(11)947285580
1194728-5580
11 94728 5580
346.549.668-32
46254966832
31604523875
10154511,55
12/56/12019';
my $regex = qr/(\d[ \-.)]{0,3}){11,20}|(\b[\d]{3}\b)[^,.]/p;
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