#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "<ForeignTable(.|\n|\r\n)*?<\/ForeignTable>"
Local $sString = "skjghkfbhkljfbvg" & @CRLF & _
"gfsdjhgisufgh" & @CRLF & _
"foreign" & @CRLF & _
"<<<>>>>>" & @CRLF & _
"<ForeignTable Name="JobPlan" Alias="FK0024">" & @CRLF & _
" <Fields>" & @CRLF & _
" <Field Name="JpDescr" Alias="F24000" />" & @CRLF & _
" </Fields>" & @CRLF & _
" <MaskInfo Rights="Add" AddContext="1">" & @CRLF & _
" <ContextStatus Context="1" Status="0" Update="True" />" & @CRLF & _
" </MaskInfo>" & @CRLF & _
" </ForeignTable>" & @CRLF & _
"fghisujfh" & @CRLF & _
"fsdoguhksujdfhg" & @CRLF & _
"isdjfogihodfuiyfkg" & @CRLF & _
"alias" & @CRLF & _
"add" & @CRLF & _
"table" & @CRLF & _
"<ForeignTable jhkjh" & @CRLF & _
"skjhgksjhfg" & @CRLF & _
"skdfjghkjsdfhg" & @CRLF & _
"</ForeignTable>"
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