#include <StringConstants.au3> ; to declare the Constants of StringRegExp
#include <Array.au3> ; UDF needed for _ArrayDisplay and _ArrayConcatenate
Local $sRegex = "(?m)(?<![{\d#])\d+(?![\d}]|st|nd|rd|th)"
Local $sString = "123abd //should match 123" & @CRLF & _
"abc345 //should match 234" & @CRLF & _
"ab2123cd // should match 2123" & @CRLF & _
"" & @CRLF & _
"{2}: Should NOT Match. //My regex Works" & @CRLF & _
"" & @CRLF & _
"{34: Should NOT Match. //My regex matches 4 in {34" & @CRLF & _
"" & @CRLF & _
"45}: Should NOT Match. //My regex matches 4 in {45" & @CRLF & _
"" & @CRLF & _
"{123}: Should NOT Match. //My regex matches 2 in {123}" & @CRLF & _
"" & @CRLF & _
"1st should NOT match" & @CRLF & _
"3th should NOT match, since it's wrong anyway" & @CRLF & _
"1nd should NOT match, since it's wrong anyway" & @CRLF & _
"" & @CRLF & _
"14th //should NOT Match" & @CRLF & _
"14 th should Match" & @CRLF & _
"" & @CRLF & _
"like 1st, 2nd, etc or #1, #2, etc"
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