#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?im)^(((1)st?|(2)nd?|(3)rd?|([4-9])th?)|(([0-9]*)(1[0-9])th?)|(([0-9]*[02-9])((1)st?|(2)nd?|(3)rd?|([04-9])th?)))$"
Local $sString = "// ordinals" & @CRLF & _
"1st" & @CRLF & _
"22nd" & @CRLF & _
"333rd" & @CRLF & _
"4444th" & @CRLF & _
"2500th" & @CRLF & _
"" & @CRLF & _
"// teens" & @CRLF & _
"11th" & @CRLF & _
"12th" & @CRLF & _
"13th" & @CRLF & _
"14th" & @CRLF & _
"15th" & @CRLF & _
"16th" & @CRLF & _
"17th" & @CRLF & _
"18th" & @CRLF & _
"19th" & @CRLF & _
"" & @CRLF & _
"// teens - hundreds" & @CRLF & _
"111th" & @CRLF & _
"112th" & @CRLF & _
"113th" & @CRLF & _
"114th" & @CRLF & _
"115th" & @CRLF & _
"116th" & @CRLF & _
"117th" & @CRLF & _
"118th" & @CRLF & _
"119th" & @CRLF & _
"" & @CRLF & _
"// teens - wrong suffix" & @CRLF & _
"11st" & @CRLF & _
"12nd" & @CRLF & _
"13rd" & @CRLF & _
"111st" & @CRLF & _
"112nd" & @CRLF & _
"113rd" & @CRLF & _
"" & @CRLF & _
"// uppercase" & @CRLF & _
"1ST" & @CRLF & _
"22ND" & @CRLF & _
"333RD" & @CRLF & _
"444TH" & @CRLF & _
"" & @CRLF & _
"// wrong suffix (do nothing)" & @CRLF & _
"0th" & @CRLF & _
"26st" & @CRLF & _
"31th" & @CRLF & _
"21rd" & @CRLF & _
"29nd"
Local $sSubst = "$3$4$5$6$8$9$11$13$14$15$16"
Local $sResult = StringRegExpReplace($sString, $sRegex, $sSubst)
MsgBox($MB_SYSTEMMODAL, "Result", $sResult)
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