#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)\b(?:2[3-9]|3[0-9]|40)\b"
Local $sString = "20" & @CRLF & _
"21" & @CRLF & _
"22" & @CRLF & _
"23" & @CRLF & _
"24" & @CRLF & _
"25" & @CRLF & _
"26" & @CRLF & _
"27" & @CRLF & _
"28" & @CRLF & _
"29" & @CRLF & _
"30" & @CRLF & _
"31" & @CRLF & _
"32" & @CRLF & _
"33" & @CRLF & _
"34" & @CRLF & _
"35" & @CRLF & _
"36" & @CRLF & _
"37" & @CRLF & _
"38" & @CRLF & _
"39" & @CRLF & _
"40" & @CRLF & _
"41" & @CRLF & _
"42" & @CRLF & _
"43" & @CRLF & _
"44" & @CRLF & _
"45" & @CRLF & _
"46" & @CRLF & _
"47" & @CRLF & _
"48" & @CRLF & _
"49" & @CRLF & _
"50" & @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