#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "\bobject-group\b\S*(?:\s+(?!object-group\b)\S*)*"
Local $sString = "object-group network FTP" & @CRLF & _
" description FTP Access" & @CRLF & _
" network-object host BCD1" & @CRLF & _
" network-object host BCD2" & @CRLF & _
"object-group network NTP" & @CRLF & _
" description NTP Access" & @CRLF & _
" network-object host ABC1" & @CRLF & _
" network-object host ABC2" & @CRLF & _
" network-object host ABC3" & @CRLF & _
"object-group service sample_service tcp" & @CRLF & _
" description Ports 1 2 3" & @CRLF & _
" port-object range 80 81" & @CRLF & _
" port-object eq pop3" & @CRLF & _
" port-object eq imap4" & @CRLF & _
" port-object range 443 444" & @CRLF & _
"object-group service 8080 tcp" & @CRLF & _
" description Servers"
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