#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)^(?:GB\d{2}[A-Z]{4}\d{14}|DE\d{20})|(?!DE|GB)[A-Z]{2}[A-Z\d]{13,}$"
Local $sString = "works as expected" & @CRLF & _
"DE12312341212312312312" & @CRLF & _
"GB12ASDF12312312312311" & @CRLF & _
"" & @CRLF & _
"this should match with fallback" & @CRLF & _
"NO1212121212121" & @CRLF & _
"BG18RZBB91550123456789" & @CRLF & _
"" & @CRLF & _
"this should not match with fallback:" & @CRLF & _
"DE1231234121231" & @CRLF & _
"GB1231231231231"
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