#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(\w* \w*)(?<!no other) bag"
Local $sString = "light red bags contain 1 bright white bag, 2 muted yellow bags." & @CRLF & _
"dark orange bags contain 3 bright white bags, 4 muted yellow bags." & @CRLF & _
"bright white bags contain 1 shiny gold bag." & @CRLF & _
"muted yellow bags contain 2 shiny gold bags, 9 faded blue bags." & @CRLF & _
"shiny gold bags contain 1 dark olive bag, 2 vibrant plum bags." & @CRLF & _
"dark olive bags contain 3 faded blue bags, 4 dotted black bags." & @CRLF & _
"vibrant plum bags contain 5 faded blue bags, 6 dotted black bags." & @CRLF & _
"faded blue bags contain no other bags." & @CRLF & _
"dotted black bags contain no other bags."
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