↓のページにこんなものがありました。
http://scripttpircs.seesaa.net/article/112296780.html
#module
#deffunc Replace var buf, var pattern, var repstr,int p1
newcom oReg, "VBScript.RegExp"
comres buf
oReg("Pattern")= pattern
if (p1=null | p1!1) : oReg("Global")= 1
if p1=1 : oReg("Global")= 0;0=1回 1=全体
oReg->"Replace" buf, repstr
delcom oReg
return
#deffunc Match var buf, var pattern
newcom oReg, "VBScript.RegExp"
comres result
oReg("Pattern")= pattern
oReg("Global")= 1
oReg->"Execute" buf
oMatches=result
rt = oMatches("Count")
if(rt>0){
repeat rt
oMatch=oMatches("Item",cnt)
Matchdata.0 = oMatch("Value")
Matchdata.1 += Matchdata.0
Matchdata.0 = ""
loop
buf = Matchdata.1
delcom oMatch
delcom oMatches
}
delcom oReg
delcom result
return rt
#global
teststr="112244aabbcc"
testptn="4"
repstr= "3"
mes "対象文字 \""+teststr+"\""
mes "検索文字 \""+testptn+"\""
mes "置換文字 \""+repstr+"\""
strcopy = teststr
Replace strcopy, testptn, repstr
mes "置換結果 \""+strcopy+"\""
strcopy =""
strcopy = teststr
Match strcopy, testptn
mes "検索結果 \""+stat+" : "+strcopy+"\""
mes "\n"
teststr="12345abcdefg"
testptn="12345"
repstr= "a"
mes "対象文字 \""+teststr+"\""
mes "検索文字 \""+testptn+"\""
mes "置換文字 \""+repstr+"\""
strcopy =""
strcopy = teststr
repeat 2
Replace strcopy, testptn, repstr,1
loop
mes "置換結果 \""+strcopy+"\""