#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?m)(((?:[+\-\/*]6+|6+[+\-\/*]|([^6]|\b)6{1,2}(?3)|(?3)6{6,}(?3)|[0-57-9]6+|6+[0-57-9])(*SKIP)(*F))|6)"
Local $sString = "66" & @CRLF & _
"老铁666这类的, 6666" & @CRLF & _
"三到五个六66666" & @CRLF & _
"5666有其他数字不替换" & @CRLF & _
"6665" & @CRLF & _
"566665" & @CRLF & _
"666666" & @CRLF & _
"66" & @CRLF & _
"+66" & @CRLF & _
"666-" & @CRLF & _
""
Local $sSubst = "六"
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