$re = '/errorCode\s*\=\s*\\\\\"(?<errorCode>[^\\\\]+)/m';
$str = '{"stream":"stderr","logtag":"P","log":"10/May/2024:09:31:53 +1000 [dgbttrfr] [correlationId=] [subject=], ERROR au.com.jbjcbdj.o.fefewgr.logging.LoggingUtil - severity = \\"ERROR\\", DateTimestamp = \\"09/May/2024 23:31:53\\", errorCode = \\"PAY_STAT_ERR_0017\\", errorMessage = \\"Not able to fetch error\\","hostname":"ip-101-156-185.ap-southeast-2.internal","host_ip":"10.56","cluster":"nod/pmn08"}';
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