#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^#\s*User@Host:\s*root\[root\]\s*@\s*localhost\s*\[\]$"
Local $sString = "# Time: 230706 17:12:48" & @CRLF & _
"# User@Host: sample[sample] @ localhost []" & @CRLF & _
"# Thread_id: 626784 Schema: sample QC_hit: No" & @CRLF & _
"# Query_time: 2.976557 Lock_time: 0.000178 Rows_sent: 0 Rows_examined: 3344231" & @CRLF & _
"# Rows_affected: 0 Bytes_sent: 195" & @CRLF & _
"SET timestamp=1688677968;" & @CRLF & _
"SELECT * from a;" & @CRLF & _
"" & @CRLF & _
"# Time: 230706 17:15:51" & @CRLF & _
"# User@Host: root[root] @ localhost []" & @CRLF & _
"# Thread_id: 627770 Schema: sample QC_hit: No" & @CRLF & _
"# Query_time: 2.581676 Lock_time: 0.000270 Rows_sent: 0 Rows_examined: 2432228" & @CRLF & _
"# Rows_affected: 0 Bytes_sent: 195" & @CRLF & _
"SET timestamp=1688678151;" & @CRLF & _
"select * from cs;" & @CRLF & _
"" & @CRLF & _
"# Time: 230706 17:13:37" & @CRLF & _
"# User@Host: sample[sample] @ localhost []" & @CRLF & _
"# Thread_id: 627027 Schema: oiemorug_wp598 QC_hit: No" & @CRLF & _
"# Query_time: 3.901325 Lock_time: 0.000145 Rows_sent: 0 Rows_examined: 3851050" & @CRLF & _
"# Rows_affected: 0 Bytes_sent: 195" & @CRLF & _
"SET timestamp=1688678017;" & @CRLF & _
"SELECT * from b" & @CRLF & _
"" & @CRLF & _
"# Time: 230706 17:15:51" & @CRLF & _
"# User@Host: root[root] @ localhost []" & @CRLF & _
"# Thread_id: 627770 Schema: sample QC_hit: No" & @CRLF & _
"# Query_time: 2.581676 Lock_time: 0.000270 Rows_sent: 0 Rows_examined: 2432228" & @CRLF & _
"# Rows_affected: 0 Bytes_sent: 195" & @CRLF & _
"SET timestamp=1688678151;" & @CRLF & _
"select * from cs"
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