use strict;
my $str = '0.1766155 0.1658146 0.3464225 0.258326 1.040629 0.3123467 0.7877846 0.1264636 0.1854926 2.235324 0 0.3128409 0.5384811 0.2159374 0.1659985 0.2901815 0.08226276 0.1323811 0.1374549 0.04583898 0.1653796 0.02095086 0.1465107 ';
my $regex = qr/(\d{1}\.\d{5,8}|0)\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