#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?i)(?:\w+\W+){0,9}?(?=.*(?:plot).*|.*(?:over).*)(?:\w+\W+){0,9}?(?=Charlie|Muir|Charlie Muir)\K(?:(?:Charlie|Muir|Charlie Muir)\s+)+"
Local $sString = "POSITIVE TESTING" & @CRLF & _
"" & @CRLF & _
"1." & @CRLF & _
"Charlie Muir was over the moon." & @CRLF & _
"next next next next next next next next next next next next next next " & @CRLF & _
"Charlie Muir was in the plot ." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"2." & @CRLF & _
"Charlie was over the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Charlie was in the plot ." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"3." & @CRLF & _
"Mr. Charlie was over the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Mr.Muir was in the plot." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"4." & @CRLF & _
"When Charlie saw the letter , Charlie was over the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"When Charlie saw the letter, ChaRLIE was walking in the plot." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"5." & @CRLF & _
"When Charlie Muir saw letter , Charlie Muir was over the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"When Charlie Muir saw letter, ChaRLIE MUIR was walking in plot." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"6." & @CRLF & _
"When Muir saw letter , Mr.Muir was over the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"When Mr.MUIR saw letter, Mr.CharliE was walking in plot." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"7." & @CRLF & _
"When Muir saw letter , Mr.Charlie Muir was over the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"When Mr.Charlie saw letter, Mr.MUIR was walking in plot." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"8." & @CRLF & _
"Charlie Muir was Over the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Charlie Muir was in the PLOT ." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"9." & @CRLF & _
"He,Charlie and Muir were OVEr the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Charlie and MR.MUIR were in the ploT ." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"10." & @CRLF & _
"Over the moon was Charlie." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Plot was far away from Charlie." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"11." & @CRLF & _
"OVER the moon was Charlie Muir." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Plot was far away from CHARLIE MUIR." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"12." & @CRLF & _
"over the moon were Charlie and Muir." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Plot was far away from Charlie and Muir." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"13." & @CRLF & _
"Over the moon was Mr.Muir whose first name is Charlie." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"PLOT was far away from Charlie whose last name is MUIR." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"14." & @CRLF & _
"OVER the moon was MUIR who is also charlie Muir." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"plot was far away from MUIR who is also CHarlie Muir." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"---------------------------------------------------------------------" & @CRLF & _
"" & @CRLF & _
"POSITVE / NEGATIVE TESTING" & @CRLF & _
"" & @CRLF & _
"15." & @CRLF & _
"Charlie knew when CHARLIE saw the letter that he would be over the moon after reading it." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Charlie knew what the letter would contain when Charlie was reading it while walking in the plot." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"16." & @CRLF & _
"Charlie knew when Charlie and muir saw the letter that they would be over the moon" & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Charlie knew when Charlie and Muir saw the letter that they would be in the plot" & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"17." & @CRLF & _
"Charlie knew when Charlie Muir saw the letter that they would be over the moon" & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Charlie knew when Charlie Muir saw the letter that they would be in the plot" & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"18." & @CRLF & _
"over the moon was Charlie Muir who is also known simply as CHARLIE." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"The plot was far away from Charlie Muir who is also known simply as CHARLIE." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"" & @CRLF & _
"19." & @CRLF & _
"OVER the moon was Mr.ChaRlie and Muir who are together known as the MuIr Brothers." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"The plot was far away from Charlie and Muir who are together known as the MUIR Brothers." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"-----------------------------------------------------------------------" & @CRLF & _
"" & @CRLF & _
"NEGATIVE TESTING" & @CRLF & _
"" & @CRLF & _
"20." & @CRLF & _
"Charlie Muir , after receiving and reading letter was addressed to him , was over the moon." & @CRLF & _
"next next next next next next next next next next next next next next" & @CRLF & _
"Charlie Muir received and read the letter was addressed to him in plot." & @CRLF & _
"next next next next next next next next next next next next next next" & @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