#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)^(?:\d{7,8}|[TD]\d{6,7}|TD\d{5,6})$"
Local $sString = "7 and 8 numbers: '1234567' and '12345678'" & @CRLF & _
"1234567" & @CRLF & _
"12345678" & @CRLF & _
"7 and 8 numbers that start with T: 'T234567' and 'T2345678'" & @CRLF & _
"T234567" & @CRLF & _
"T2345678" & @CRLF & _
"7 and 8 numbers that start with D: 'D234567' and 'D2345678'" & @CRLF & _
"D234567" & @CRLF & _
"D2345678" & @CRLF & _
"7 and 8 numbers that start with TD: 'TD34567' and 'TD345678'" & @CRLF & _
"TD34567" & @CRLF & _
"TD345678"
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