$re = '/(?P<event_message>A user account was unlocked\.)\s+Subject:\s+Security ID:\s+(?P<subject_security_id>.*?)\s+Account Name:\s+(?P<subject_account_name>.*?)\s+Account Domain:\s+(?P<subject_account_domain>.*?)\s+Logon ID:\s+(?P<subject_logon_id>.*?)\s+Target Account:\s+Security ID:(?P<target_security_id>.*?)\s+Account Name:\s+(?P<target_account_name>.*?)\s+Account Domain:\s+(?P<target_account_domain>.*)/';
$str = 'A user account was unlocked. Subject: Security ID: S-1-5-21-173871781-544419543-443003237-500 Account Name: Administrator Account Domain: AV Logon ID: 0x1E3AD Target Account: Security ID: S-1-5-21-173871781-544419543-443003237-1111 Account Name: test Account Domain: AV';
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