#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)[A-HJ-NP-TV-Z]{2}[\s-]{0,1}[0-9]{3}[\s-]{0,1}[A-HJ-NP-TV-Z]{2}|[0-9]{2,4}[\s-]{0,1}[A-Z]{1,3}[\s-]{0,1}[0-9]{2}"
Local $sString = "## OLD FROMAT (complete) ##" & @CRLF & _
"3123 AA 11" & @CRLF & _
"3123-AA-11" & @CRLF & _
"3123AA11" & @CRLF & _
"8987 VG 33" & @CRLF & _
"8987VG33" & @CRLF & _
"" & @CRLF & _
"## OLD FORMAT (with few characters) ##" & @CRLF & _
"31 F 11" & @CRLF & _
"" & @CRLF & _
"## NEW FORMAT ##" & @CRLF & _
"AA 123 BB" & @CRLF & _
"AA-222-BB" & @CRLF & _
"DD345EE" & @CRLF & _
"" & @CRLF & _
"AO 123 BB // O is excluded" & @CRLF & _
"AI-123-BB // I is excluded" & @CRLF & _
"AU123BB // U is exclided" & @CRLF & _
"AZ 123 BI" & @CRLF & _
"AZ-123-BU" & @CRLF & _
"AZ123BO"
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