#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^\d{4}(\d{2})?$"
Local $sString = "123413" & @CRLF & _
"87623" & @CRLF & _
"2342" & @CRLF & _
"342" & @CRLF & _
"12" & @CRLF & _
"4" & @CRLF & _
"412" & @CRLF & _
"3412" & @CRLF & _
"31123" & @CRLF & _
"2341234" & @CRLF & _
"23412342341234234123423412342341234234123423412342341234234123423" & @CRLF & _
"2341234234123423412342341234234123423412342341234234123423412342" & @CRLF & _
"234123423412342341234234123423412342341234234123423412342341234" & @CRLF & _
"23412342341234234123423412342341234234123423412342341234234123" & @CRLF & _
"234123423412342341234234123423412342341234234123423412342341" & @CRLF & _
"23412342341234234123423412342341234234123423412342341234234" & @CRLF & _
"4333" & @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