#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?mi)(err\s*?\d{1})|[^\d]\s+(\d{3})(?:$|\s+(?!\d))"
Local $sString = "The below items should match:" & @CRLF & _
"-----------------------------" & @CRLF & _
"123" & @CRLF & _
"456 123" & @CRLF & _
"123 324 324" & @CRLF & _
"Match the number in this sentence 123 as well" & @CRLF & _
"999" & @CRLF & _
"" & @CRLF & _
"The below items should NOT match:" & @CRLF & _
"---------------------------------" & @CRLF & _
"1234" & @CRLF & _
"12345" & @CRLF & _
"123456" & @CRLF & _
"1234567" & @CRLF & _
"" & @CRLF & _
"£123" & @CRLF & _
"$456" & @CRLF & _
"" & @CRLF & _
"Err404" & @CRLF & _
"ERR404" & @CRLF & _
"err404" & @CRLF & _
"Err 404" & @CRLF & _
"ERR 404" & @CRLF & _
"err 404" & @CRLF & _
"" & @CRLF & _
"there is err 404 on page" & @CRLF & _
"this err 1232222222222 as well" & @CRLF & _
"" & @CRLF & _
"a string 12323 like this" & @CRLF & _
"asd" & @CRLF & _
"4444333322221111" & @CRLF & _
"4444 3333 2222 1111" & @CRLF & _
"Err123" & @CRLF & _
"" & @CRLF & _
"02012341234" & @CRLF & _
"920 1234 1234"
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