#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "\b004010H2[127][02379](?:A[12])?\b"
Local $sString = "$str = "this is the code 004010H222A1 the rest is irrelevant";" & @CRLF & _
"$str = "the random number is 004010H223A2 ** anything else is irrelevant";" & @CRLF & _
"$str = "the last lottery number 004010H220A1 ~~ the rest is irrelevant";" & @CRLF & _
"$str = "yet another random sentence 004010H279A1 the rest is irrelevant";" & @CRLF & _
"$str = "any sentence before what i want 004010H279A1 the rest is irrelevant";" & @CRLF & _
"$str = "last winning number 004010H217~~~";" & @CRLF & _
""
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