#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?im)^(?:[a-z\d]{3,}[_ ](?:[a-z\d]{2,}[_ ][a-z\d]{4,})?)?[a-z\d]*$"
Local $sString = "Valid:" & @CRLF & _
"a" & @CRLF & _
"b1" & @CRLF & _
"abcdefg" & @CRLF & _
"123_VBV" & @CRLF & _
"123_ABC_ERRR" & @CRLF & _
"12345" & @CRLF & _
"123456789abcdefg" & @CRLF & _
"123_AB_YYYY" & @CRLF & _
"123_ABC_YYYY" & @CRLF & _
"" & @CRLF & _
"Invalid:" & @CRLF & _
"123__" & @CRLF & _
"123_gg_" & @CRLF & _
"_12345" & @CRLF & _
"1 2345" & @CRLF & _
"123 a_bc" & @CRLF & _
"123_ 45" & @CRLF & _
"123__45" & @CRLF & _
"123 45" & @CRLF & _
"123_gg_" & @CRLF & _
"123_VBV_HH_" & @CRLF & _
"Foo_Bar_Baz_123" & @CRLF & _
"Foo Bar_Baz_123" & @CRLF & _
"123_AB_YYY" & @CRLF & _
"123_ggg_"
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