#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?ix)(" & @CRLF & _
".*" & @CRLF & _
"\b(why|what)\b" & @CRLF & _
".*" & @CRLF & _
"\?" & @CRLF & _
"){2,}"
Local $sString = "" & @CRLF & _
"1) What I love u? Look at me. Why I love u?" & @CRLF & _
"3) Why do you look at me?" & @CRLF & _
"4) Are you alright?" & @CRLF & _
"5) I am sick. How are you?. Well you do not have to answer it. what's up?" & @CRLF & _
"6) How are you? I am sick. What's up? Well you do not have to answer it. " & @CRLF & _
"7) Why I love u?" & @CRLF & _
"8) Any questions? No. Why not? Sure? Ok?" & @CRLF & _
"9) Jesus christ. You know what, do I love u? Look at me! Why I love u?" & @CRLF & _
"10) what do you want? what do you mean?" & @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