#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s)Account For Which Logon Failed.* Account Name:.+?\b(.*?)\s"
Local $sString = " An account failed to log on." & @CRLF & _
"" & @CRLF & _
" Subject:" & @CRLF & _
" Security ID: S-1-5-21-1287344763-2688370722-3395302928-19873" & @CRLF & _
" Account Name: service_adfs" & @CRLF & _
" Account Domain: DOMAIN" & @CRLF & _
" Logon ID: 0xD62E4" & @CRLF & _
"" & @CRLF & _
" Logon Type: 3" & @CRLF & _
"" & @CRLF & _
" Account For Which Logon Failed:" & @CRLF & _
" Security ID: S-1-0-0" & @CRLF & _
" Account Name: user.thatiwant@DOMAIN.com" & @CRLF & _
" Account Domain: "
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYFULLMATCH)
; Present the entire match result
_ArrayDisplay($aArray, "Result")
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 AutoIt, please visit: https://www.autoitscript.com/autoit3/docs/functions/StringRegExp.htm