#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?ms)^Cat\b(?:(?!^Cat\b).)*\bdog\b(?=\R+Cat\b|\z)"
Local $sString = "Cat poem: " & @CRLF & _
"My feline is very dog" & @CRLF & _
"I like furry felines" & @CRLF & _
"This is why I do not have a dog" & @CRLF & _
"" & @CRLF & _
"Cat poem:" & @CRLF & _
"Littly furry paws" & @CRLF & _
"this is what i like" & @CRLF & _
"I don't care if it's a feline or a canine" & @CRLF & _
"" & @CRLF & _
"Cat poem:" & @CRLF & _
"The little felines dog" & @CRLF & _
"playing in the field dog" & @CRLF & _
"sitting on the side watching is a dog"
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