$re = '/\d{4}-\d{2}-\d{2}T\d\d:\d\d:\d\d+\+\d\d:\d\d\s+(?<device>[^ ]+)\s+\<\d+\>\s+\%(?<alarm>\w+-\w+)[^ ]*\s+\(\d+\)\s+(?<message>[^\(]+)((\s+\(\d+\s+)|$)/m';
$str = '2020-04-04T15:08:01+00:00 usdaldc <44> %WAAS-HTTPAO-4-131001: (843570) worker pool isn\'t healthy
2020-04-04T15:08:01+00:00 usdaldc <43> %WAAS-HTTPAO-3-131003: (843509) AOSHELL worker thread (28814 0.0) stuck for 650000 msec: start 0x7feedd6aa880(/cisco/lib64/libaoshell.so+0x50880), callback 0x4a6140(/sw/unicorn/bin/http_ao64+0xa6140)';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
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 PHP, please visit: http://php.net/manual/en/ref.pcre.php