use strict;
my $str = '1R43AG048651−01A1
1R43AG048651-01A1
1x
1X
1X
1x
abc10
100
xyz
abc10a
10xyz
10xyz1
10XYz1
AbC10a
a1b2c3d4
100nm
Test 123test 100ppm 123test
テスト123testテスト123testテスト100ppmテスト
10mol
10v/v
10mmol
100mg/kg
10 mg/kg';
my $regex = qr/(?:[0-90-9]+[ⅠⅡⅢⅣⅥⅦⅧⅨⅪⅫⅤⅩⅬⅭⅮⅯA-zA-z]+|[ⅠⅡⅢⅣⅥⅦⅧⅨⅪⅫⅤⅩⅬⅭⅮⅯA-zA-z]+[0-90-9]+)[ⅠⅡⅢⅣⅥⅦⅧⅨⅪⅫⅤⅩⅬⅭⅮⅯA-zA-z0-90-9]*(?<!mg/kg|mg\/kg|nm|nm|MHz|ppm|ppm|mmol|mmol|g|g|g|mL|mL|mol|mol|nM|nM|μL|v\/v)/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