#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?i)[^`\w@\\](t[xyq]|th(nx|nq|x)|than[xk](s)?(you|[syxzq]){0,1})\b"
Local $sString = "#- Should match" & @CRLF & _
"tx, ty, tq," & @CRLF & _
"thnq, thx, thnx," & @CRLF & _
"thanx, thanxyou, thanxs, thanxy, thanxx, thanxz, thanxq, thanxss, thanxsy, thanxsx, thanxsz, thanxsq" & @CRLF & _
"thank, thankyou, thanks, thanky, thankx, thankz, thankq, thankss, thanksy, thanksx, thanksz, thanksq" & @CRLF & _
"..." & @CRLF & _
"" & @CRLF & _
"" & @CRLF & _
"#- Shouldn't work" & @CRLF & _
"thanksk" & @CRLF & _
"thans" & @CRLF & _
"than" & @CRLF & _
"thanker" & @CRLF & _
"thanking" & @CRLF & _
"thxq" & @CRLF & _
"thnxs" & @CRLF & _
"txs" & @CRLF & _
"taxs" & @CRLF & _
"`thanks`" & @CRLF & _
"``` a real world testing of thanks regex ```" & @CRLF & _
"_thanks_" & @CRLF & _
"tank of pleasure" & @CRLF & _
"tax is high" & @CRLF & _
"taks away!" & @CRLF & _
"tanks are everywhere" & @CRLF & _
"@thanks buddy" & @CRLF & _
"# Shouldn't match" & @CRLF & _
"@thanks" & @CRLF & _
"@tanks" & @CRLF & _
"@tx" & @CRLF & _
"@ty" & @CRLF & _
"thankqx"
Local $sSubst = "$1"
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