use strict;
my $str = 'Of course, 22d,3 equals 22,3, or A equals (empty string), 12 equals 12, need to remove anything that\'s not a number and my separator for float is ,
This is a 12 test with 12,34 digits and 123.23 or 123,1 or 123,12 or123,123 and 1234,1 but not 1,234 .html
test-test
34,344
34,34
34,1
34.1
1
1,1
1,12
12
100000
This is a ,comma here and ,,,,,3where ,
,,
,
This is , a a test 10,2333';
my $regex = qr/[^\d,]+|,+\D|\D,+|\d+,\d{3,}|\d{3,}(?:,\d+)?|^,|,$/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