use strict;
my $str = '2018-03-05 22:52:52 INFO (app.go:391) - flush done sketch={flushed=264557 total=57979680 pruned=295} num_org_metric=448 since_ms=10964ms dt=2.2392s
2018-03-05 22:53:01 INFO (app.go:391) - flush done sketch={flushed=171045 total=57954960 pruned=253} num_org_metric=448 since_ms=9377ms dt=1.616403s
2018-03-05 22:53:10 INFO (app.go:391) - flush done sketch={flushed=190064 total=57933000 pruned=297} num_org_metric=448 since_ms=9366ms dt=982.968ms
2018-03-05 22:53:20 INFO (app.go:391) - flush done sketch={flushed=153243 total=57932520 pruned=89} num_org_metric=448 since_ms=9908ms dt=891.573ms';
my $regex = qr/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \S+ \(\S+\) - flush done sketch={flushed=(\d+) total=(\d+) pruned=(\d+)} num_org_metric=\d+ since_ms=(\d+)ms dt=[-+]?([0-9]*(\.[0-9]*)?[a-z]+)+/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