#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m).*told me to say.*"
Local $sString = "ex1: I am * years old" & @CRLF & _
"valid matches:" & @CRLF & _
"- "I am 24 years old"" & @CRLF & _
"- "I am twenty four years old"" & @CRLF & _
"" & @CRLF & _
"ex2: what color is [my|your|his|her] (bright red|blue|green|lemon chiffon) *" & @CRLF & _
"valid matches:" & @CRLF & _
"- "what color is his lemon chiffon car"" & @CRLF & _
"- "what color is my some random text till the end of string"" & @CRLF & _
"" & @CRLF & _
"ex3: [*] told me to say *" & @CRLF & _
"valid matches:" & @CRLF & _
"- "Bob and Alice told me to say hallelujah"" & @CRLF & _
"- "told me to say by nobody""
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