#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?s){(?=[^}]*?host_name\s*([^\s]+))(?=[^}]*?_LBZ\s*LBZ#(425964))(?=[^}]*?_TARGETIP\s*([^\s]+))"
Local $sString = "define host {" & @CRLF & _
" use host-template" & @CRLF & _
" host_name server-01" & @CRLF & _
" display_name server-01-display-name" & @CRLF & _
" address 10.0.0.1" & @CRLF & _
" _CUSTOMEREMAIL customer01@mail.com" & @CRLF & _
" _LBZ LBZ#10178541" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"define service {" & @CRLF & _
" use host-template" & @CRLF & _
" host_name server-02" & @CRLF & _
" service_description server-02" & @CRLF & _
" servicegroups wlan" & @CRLF & _
" display_name server-02" & @CRLF & _
" _LBZ LBZ#425964" & @CRLF & _
" _TARGETIP 10.0.0.2" & @CRLF & _
" _CUSTOMEREMAIL customer5@mail.com" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"define service {" & @CRLF & _
" use host-template" & @CRLF & _
" host_name server-03" & @CRLF & _
" service_description server-03" & @CRLF & _
" servicegroups wlan" & @CRLF & _
" display_name server-04" & @CRLF & _
" _LBZ LBZ#421264" & @CRLF & _
" _TARGETIP 10.0.0.3" & @CRLF & _
" _CUSTOMEREMAIL customer01@mail.com" & @CRLF & _
"}" & @CRLF & _
"" & @CRLF & _
"define host {" & @CRLF & _
" use host-template" & @CRLF & _
" host_name server-04" & @CRLF & _
" display_name server-04" & @CRLF & _
" address 10.0.0.4" & @CRLF & _
" _CUSTOMEREMAIL customer02@mail.com" & @CRLF & _
" _LBZ LBZ#12300541" & @CRLF & _
"}"
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