#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^9?[\d]{4}-[\d]{4}$"
Local $sString = "# 8 dígitos sem traço" & @CRLF & _
"12345678" & @CRLF & _
"92841742" & @CRLF & _
"83457854" & @CRLF & _
"" & @CRLF & _
"# 9 dígitos sem traço" & @CRLF & _
"123457890" & @CRLF & _
"899879878" & @CRLF & _
"983457854" & @CRLF & _
"912345678" & @CRLF & _
"" & @CRLF & _
"# 8 dígitos com traço" & @CRLF & _
"1234-5678" & @CRLF & _
"9284-1742" & @CRLF & _
"8345-7854" & @CRLF & _
"" & @CRLF & _
"# 9 dígitos com traço" & @CRLF & _
"12345-7890" & @CRLF & _
"89987-9878" & @CRLF & _
"98345-7854" & @CRLF & _
"91234-5678"
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