use strict;
my $str = '2022-06-27T15:22:35.506+00:00 [Info] MSAT starting with 60000 tick ...
2022-06-27T15:22:35.506+00:00 [Info] pram[:9999] starting ...
2022-06-27T15:22:35.508+00:00 [Info] New settings received:
{"indexer.settings.compaction.days_of_week":"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday","indexer.settings.compaction.interval":"00:00,00:00","indexer.settings.compaction.compaction_mode":"circular","indexer.settings.log_level":"info","indexer.settings.persisted_snapshot.interval":5000,"indexer.settings.compaction.min_frag":30,"indexer.settings.inmemory_snapshot.interval":200,"indexer.settings.max_cpu_percent":0,"indexer.settings.storage_mode":"forestdb","indexer.settings.recovery.max_rollbacks":5,"indexer.settings.memory_quota":1073741824,"indexer.settings.compaction.abort_exceed_interval":false}
2022-06-27T15:22:35.508+00:00 [Info] PROJ[:9999] settings notifier from metakv
';
my $regex = qr/^(?<timestamp>\d+-\d+-\d+T\d+:\d+:\d+\.\d+([+-])\d+:\d+)\s+\[(?<severity>\w+)\](?<message>.*(?:\n(?!\d+-\d+-\d+T).*)*)$/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