use strict;
my $str = 'Sep 19 09:23:01 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-64-6e/crm_attribute/4, version=0.1352.0)
Sep 19 09:23:06 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0xe2bf50 0)
Sep 19 09:30:53 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-64-50/crm_attribute/4, version=0.1352.0)
Sep 19 09:30:58 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0xe2e450 0)
Sep 19 09:37:59 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-65-68/crm_attribute/4, version=0.1352.0)
Sep 19 09:38:04 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0xe372d0 0)
Sep 19 09:43:25 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Forwarding cib_modify operation for section nodes to master (origin=local/crm_attribute/4)
Sep 19 09:43:25 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-64-6e/crm_attribute/4, version=0.1352.0)
Sep 19 09:43:30 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0xe2be50 0)
Sep 19 09:46:55 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-64-50/crm_attribute/4, version=0.1352.0)
Sep 19 09:47:00 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0xeead20 0)
Sep 19 09:54:03 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-65-68/crm_attribute/4, version=0.1352.0)
Sep 19 09:54:08 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0x129d470 0)
Sep 19 10:02:51 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-64-50/crm_attribute/4, version=0.1352.0)
Sep 19 10:02:56 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0xe2e450 0)
Sep 19 10:03:38 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Forwarding cib_modify operation for section nodes to master (origin=local/crm_attribute/4)
Sep 19 10:03:38 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-64-6e/crm_attribute/4, version=0.1352.0)
Sep 19 10:03:43 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0xb60f30 0)
Sep 19 10:10:11 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-65-68/crm_attribute/4, version=0.1352.0)
Sep 19 10:10:16 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0xd963e0 0)
Sep 19 10:18:44 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_request: Completed cib_modify operation for section nodes: OK (rc=0, origin=d2c-76-8a-ac-64-50/crm_attribute/4, version=0.1352.0)
Sep 19 10:18:49 [16818] d2c-76-8a-ac-64-6e cib: info: cib_process_ping: Reporting our current digest to d2c-76-8a-ac-64-50: bc17de2aedf4d53c3f4fa8021fffd2b1 for 0.1352.0 (0x129d4f0 0)';
my $regex = qr/^\s*(?<time>[^ ]* {1,2}[^ ]* [^ ]*) \[(?<pid>\d+)\] (?<macid>[\-\w]*)\s*(?<component>\w*):\s+(?<severity>\w+):\s+(?<action>\w+):\s+(?<action_status>\w+) (?<mesage>[^\(]*) (\((?<meta>.*)\))$/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