#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)((ltm virtual) ([a-zA-Z0-9_-]*) {(.|\n)*?})"
Local $sString = "Some Garbage text" & @CRLF & _
"ltm virtual The_Name_51244_sdfasfdasd {" & @CRLF & _
" address-status yes" & @CRLF & _
" enabled" & @CRLF & _
" fallback-persistence none" & @CRLF & _
" profiles {" & @CRLF & _
" /Common/GLOBAL_PROFILE {" & @CRLF & _
" context all" & @CRLF & _
" }" & @CRLF & _
" /Common/http {" & @CRLF & _
" context all" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" rate-class none" & @CRLF & _
" rules {" & @CRLF & _
" /Common/X-F-F" & @CRLF & _
" }" & @CRLF & _
" log-profiles none" & @CRLF & _
" source-address-translation {" & @CRLF & _
" pool SOME-SNAT-POOL" & @CRLF & _
" type snat" & @CRLF & _
" }" & @CRLF & _
" source-port preserve" & @CRLF & _
" vlans {" & @CRLF & _
" Vlan1111" & @CRLF & _
" }" & @CRLF & _
" service-down-immediate-action none" & @CRLF & _
" service-policy none" & @CRLF & _
" source 0.0.0.0/0" & @CRLF & _
"}" & @CRLF & _
"barbage text" & @CRLF & _
"ltm virtual The_Object_51244 {" & @CRLF & _
" address-status yes" & @CRLF & _
" enabled" & @CRLF & _
" fallback-persistence none" & @CRLF & _
" profiles {" & @CRLF & _
" /Common/GLOBAL_PROFILE {" & @CRLF & _
" context all" & @CRLF & _
" }" & @CRLF & _
" /Common/http {" & @CRLF & _
" context all" & @CRLF & _
" }" & @CRLF & _
" }" & @CRLF & _
" rate-class none" & @CRLF & _
" rules {" & @CRLF & _
" /Common/X-F-F" & @CRLF & _
" }" & @CRLF & _
" log-profiles none" & @CRLF & _
" source-address-translation {" & @CRLF & _
" pool SOME-SNAT-POOL" & @CRLF & _
" type snat" & @CRLF & _
" }" & @CRLF & _
" source-port preserve" & @CRLF & _
" vlans {" & @CRLF & _
" Vlan2222" & @CRLF & _
" }" & @CRLF & _
" service-down-immediate-action none" & @CRLF & _
" service-policy none" & @CRLF & _
" source 0.0.0.0/0" & @CRLF & _
"}" & @CRLF & _
"Trailing garbage text"
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