#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?ms)Target Account:.*Security ID:\s+(?<Security_ID>[^ ]*)"
Local $sString = " LogName=Security" & @CRLF & _
" SourceName=Microsoft Windows security auditing." & @CRLF & _
" EventCode=4738" & @CRLF & _
" EventType=0" & @CRLF & _
" Type=Information" & @CRLF & _
" ComputerName=server.domain.com" & @CRLF & _
" TaskCategory=User Account Management" & @CRLF & _
" OpCode=Info" & @CRLF & _
" RecordNumber=00000000" & @CRLF & _
" Keywords=Audit Success" & @CRLF & _
" Message=A user account was changed." & @CRLF & _
" " & @CRLF & _
" Subject:" & @CRLF & _
" Security ID: DOMAIN\account_1" & @CRLF & _
" Account Name: account_1" & @CRLF & _
" Account Domain: DOMAIN" & @CRLF & _
" Logon ID: 0000000" & @CRLF & _
" " & @CRLF & _
" Target Account:" & @CRLF & _
" Security ID: DOMAIN\account_2" & @CRLF & _
" Account Name: account_2" & @CRLF & _
" Account Domain: DOMAIN"
Local $aArray = StringRegExp($sString, $sRegex, $STR_REGEXPARRAYGLOBALFULLMATCH)
Local $aFullArray[0]
For $i = 0 To UBound($aArray) -1
_ArrayConcatenate($aFullArray, $aArray[$i])
Next
$aArray = $aFullArray
; 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