#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?ms)System Message: (?<agent>\w+) is ready to chat.*?[\r\n]+[\d\/]+\s+[\d:]+\s+\w+\s+[\r\n]+(?P=agent)[\r\n]+(?<agentFirstResponse>.*?)[\r\n]+[\d\/]+\s+[\d:]+\s+\w+"
Local $sString = "1/1/2019 2:42:55 AM " & @CRLF & _
"Aju " & @CRLF & _
"Hi Team" & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:42:56 AM " & @CRLF & _
"System " & @CRLF & _
"The data has been added: " & @CRLF & _
"- Customer Info" & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:42:59 AM " & @CRLF & _
"Rohi" & @CRLF & _
"System Message: Rohi is ready to chat. " & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:43:09 AM " & @CRLF & _
"Aju " & @CRLF & _
"Wish you a very happy ne year " & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:43:12 AM " & @CRLF & _
"Aju " & @CRLF & _
"new* " & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:43:25 AM " & @CRLF & _
"Aju " & @CRLF & _
"I need to KNOW ABOUT A CAR" & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:43:32 AM " & @CRLF & _
"Aju " & @CRLF & _
"please help me " & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:45:07 AM " & @CRLF & _
"Aju " & @CRLF & _
"Anyone there ? " & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:47:13 AM " & @CRLF & _
"Aju " & @CRLF & _
"?? " & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:49:23 AM " & @CRLF & _
"Aju " & @CRLF & _
"?? Hi Rohi You there? " & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:51:16 AM " & @CRLF & _
"Rohi" & @CRLF & _
"Hello Aju my name is Rohi. How can I help you today? " & @CRLF & _
"" & @CRLF & _
"1/1/2019 2:51:27 AM" & @CRLF & _
"" & @CRLF & _
"Chat goes on...."
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