use strict;
my $str = '// Valid values
-90.000000
90.000000
1.000000
-1.000000
9.999999
88.888888
77.777777
66.666666
55.555555
44.444444
33.333333
22.222222
11.111111
00.000000
-9.999999
-88.888888
-77.777777
-66.666666
-55.555555
-44.444444
-33.333333
-22.222222
-11.111111
// Invalid values
-90.000001
-90.000010
-90.000100
-90.001000
-90.010000
-90.100000
-91.000000
90.000001
90.000010
90.000100
90.001000
90.010000
90.100000
91.000000
+190.000000
190.000000
-190.000000
-90.00000
-90.0000
-90.000
-90.00
-90.0
-90.
-90
-9
190.000000
90.00000
90.0000
90.000
90.00
90.0
90.
90
9
';
my $regex = qr/^[+|-]?(90.0{6}|[0-8]?[0-9].[0-9]{6})$/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