#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?xmi)^ # begin of string" & @CRLF & _
"(?:(?!(?:\1|\2|\3)).)*? # ungreedy anything that is not captured by group 1,2,or 3" & @CRLF & _
" ( # 1th capturing group" & @CRLF & _
" (?:\brain\b|\bsunlight\b|\bbark) # Alternation group (answers) \b word-boundaries as needed" & @CRLF & _
" )" & @CRLF & _
"(?:(?!(?:\1|\2|\3)).)*? # ungreedy anything that is not captured by group 1,2,or 3" & @CRLF & _
" ( # 3th capturing group" & @CRLF & _
" (?:(?!(?:\1|\3))(?:\brain\b|\bsunlight\b|\bbark)) # Answers not captured in group 1 or 3" & @CRLF & _
" )" & @CRLF & _
"(?:(?!(?:\1|\2|\3)).)*? # ungreedy anything that is not captured by group 1,2,or 3" & @CRLF & _
" ( # 4th capturing group" & @CRLF & _
" (?:(?!(?:\2|\3))(?:\brain\b|\bsunlight\b|\bbark)) # Answers not captured by group 2 or 3" & @CRLF & _
" )" & @CRLF & _
"(?:(?!(?:\1|\2|\3)).)* # anything that is not captured by group 1,2,or 3" & @CRLF & _
"$ # end of string"
Local $sString = "rain. bright sunlight. a dog's bark." & @CRLF & _
"rain. bright rain. a dog's bark." & @CRLF & _
"Barksunlight rain" & @CRLF & _
"bark sun rain" & @CRLF & _
"bar sunlight sunlight" & @CRLF & _
"Rain rain rain" & @CRLF & _
"sunlight rain bark" & @CRLF & _
"Barking dog, sunlight, rainforest" & @CRLF & _
"Barking elephant, green Sunlight, purple rain and other non-sense" & @CRLF & _
"" & @CRLF & _
""
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