use strict;
my $str = '
22/09/2015 11:05:41 | Dispense complete for COTTON, final dispense weight was 0.0262
22/09/2015 11:08:02 | Dispense complete for COTTON, final dispense weight was 0.0264
22/09/2015 11:10:08 | Dispense complete for COTTON, final dispense weight was 0.0229
22/09/2015 11:12:03 | Dispense complete for COTTON, final dispense weight was 0.0188
22/09/2015 11:14:22 | Dispense complete for COTTON, final dispense weight was 0.0292
22/09/2015 11:16:48 | Dispense complete for COTTON, final dispense weight was 0.0245
22/09/2015 11:18:37 | Dispense complete for COTTON, final dispense weight was 0.0243
22/09/2015 11:20:56 | Dispense complete for COTTON, final dispense weight was 0.0261
22/09/2015 11:22:53 | Dispense complete for COTTON, final dispense weight was 0.0228
22/09/2015 11:24:43 | Dispense complete for COTTON, final dispense weight was 0.0204
22/09/2015 11:26:38 | Dispense complete for COTTON, final dispense weight was 0.0223
22/09/2015 11:28:29 | Dispense complete for COTTON, final dispense weight was 0.0257
22/09/2015 11:30:20 | Dispense complete for COTTON, final dispense weight was 0.0371
22/09/2015 11:32:14 | Dispense complete for COTTON, final dispense weight was 0.0376
22/09/2015 11:36:18 | Dispense complete for COTTON, final dispense weight was 0.0222
22/09/2015 11:39:28 | Dispense complete for COTTON, final dispense weight was 0.0234
22/09/2015 11:41:23 | Dispense complete for COTTON, final dispense weight was 0.0255
22/09/2015 11:43:24 | Dispense complete for COTTON, final dispense weight was 0.0242
22/09/2015 11:46:30 | Dispense complete for COTTON, final dispense weight was 0.0354
22/09/2015 11:50:04 | Dispense complete for COTTON, final dispense weight was 0.0294';
my $regex = qr/(?:\d*\.)?\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