#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?ms)^config system interface$(?:(?!^end$).)+^end$"
Local $sString = "config system accprofile" & @CRLF & _
" edit "prof_admin"" & @CRLF & _
" set mntgrp read-write" & @CRLF & _
" set admingrp read-write" & @CRLF & _
" next" & @CRLF & _
"end" & @CRLF & _
"config system interface" & @CRLF & _
" edit "port1"" & @CRLF & _
" set vdom "root"" & @CRLF & _
" set ip 192.168.0.150 255.255.255.0" & @CRLF & _
" set allowaccess ping https ssh http telnet" & @CRLF & _
" set type physical" & @CRLF & _
" set role wan" & @CRLF & _
" set snmp-index 1" & @CRLF & _
" next" & @CRLF & _
" edit "port2"" & @CRLF & _
" set vdom "root"" & @CRLF & _
" set type physical" & @CRLF & _
" set role wan" & @CRLF & _
" set snmp-index 2" & @CRLF & _
" next" & @CRLF & _
"end" & @CRLF & _
"config system interface" & @CRLF & _
" edit "port3"" & @CRLF & _
" set vdom "root"" & @CRLF & _
" set ip 192.168.0.150 255.255.255.0" & @CRLF & _
" next" & @CRLF & _
" edit "port4"" & @CRLF & _
" set role wan" & @CRLF & _
" set snmp-index 2" & @CRLF & _
" next" & @CRLF & _
"end"
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