#include <MsgBoxConstants.au3> ; to declare the Constants of MsgBox
Local $sRegex = "(?sx)(0|1|2|3|4|5|6|7|8|9)" & @CRLF & _
"(?=.*:\1=(\w+))"
Local $sString = "0 zero " & @CRLF & _
"1 ichi " & @CRLF & _
"2 ni " & @CRLF & _
"3 san " & @CRLF & _
"4 shi " & @CRLF & _
"5 go" & @CRLF & _
"6 roku" & @CRLF & _
"7 shichi" & @CRLF & _
"8 hachi" & @CRLF & _
"9 kyuu" & @CRLF & _
"Dictionary:0=0:1=1:2=2:3=3:4=4:5=5:6=6:7=7:8=8:9=9"
Local $sSubst = "\2"
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