use strict;
my $str = '04:46:03.318 INFO SprywareDirectFeedQuoteHandler:secondary Processed 136726 quote messages for service NSDQ Direct Feed seq no: 835534 Latency: 1 ms exchange time: 2016-05-17 04:46:03.317 msg rate: 25.157 msgs/sec Packets on client queue: 0, packets on client buffer: 0, packets on server queue: 0, server latency: 0.032 ms, round trip time: 0.103 ms, quote cnt: 136725';
my $regex = qr/([\d\s:,.-]+)\s+\w+\s+\w+QuoteHandler:(\w+)\s+Processed\s+(\d+)\s+quote\s+messages\s+for\s+service\s+([\w\s]+)\s+seq\sno:\s+(\d+)\s+Latency:\s+([-\d\.]+)\s+ms\s+exchange time:\s+([\d+\-\:\.\s]+)msg rate:\s+([\d\.]+)\s+msgs\/sec\s+Packets\s+on\s+client\s+queue:\s+(\d+),\s+packets\s+on\s+client\s+buffer:\s+(\d+),\s+packets\s+on\s+server\s+queue:\s+(\d+),\s+server\s+latency:\s+([\d\.]+)\s+ms,\s+round\s+trip\s+time:\s+([\d\.]+)\s+ms,\s+\w+\s+cnt:\s+(\d+)/p;
if ( $str =~ /$regex/ ) {
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