#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?u)(?s)\bgood(?!.*?good.*?bad).*?\bbad.*?\bgood"
Local $sString = "^(?=.*?\bmust-have\b)(?=.*?\bmandatory\b)((?!avoid|illegal).)*$" & @CRLF & _
"" & @CRLF & _
"good 1 dfd" & @CRLF & _
"kjkkjdf" & @CRLF & _
"" & @CRLF & _
"good 2 qdqsd" & @CRLF & _
"jkfkjg" & @CRLF & _
"skdlsk" & @CRLF & _
"" & @CRLF & _
"good 3 ggrfdfdfd" & @CRLF & _
"dfklfd" & @CRLF & _
"dfkl" & @CRLF & _
"random length" & @CRLF & _
"with multiple lines" & @CRLF & _
"" & @CRLF & _
"bad 4 sdjqklj random length" & @CRLF & _
"sd4s54 multiple lines" & @CRLF & _
"" & @CRLF & _
"good 5 mlp" & @CRLF & _
"sldsklds" & @CRLF & _
"" & @CRLF & _
"ba"
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