日期:2014-05-17  浏览次数:20917 次

UBB代码替换问题 谢谢帮忙
把[face1] [face2] …… 一直到 [face20] 替换成 <img src="img/1.jpg"> 一直到 <img src="img/20.jpg">
我只能一个一个的替换 怎样能一下子替换全部啊?

还有怎么能获取表情的个数啊?

------解决方案--------------------
VBScript code
Dim regex, result

Set regex = New RegExp
regex.Pattern    = "\[face(\d+)\]"
regex.IgnoreCase = True
regex.Global     = True
result = regex.Replace(strIn, "<img src=""img/$1.jpg"">")
Set regex = Nothing


Response.Write result

------解决方案--------------------
VBScript code

Dim regex, strin, result, count
strin = "asdf[face1]dsdafasdfdsf[face12]dasf[face3]asdf[face5]asdf"

Set regex = New RegExp
regex.Pattern    = "\[face(\d+)\]"
regex.IgnoreCase = True
regex.Global     = True
result = regex.Replace(strin, "<img src=""img/$1.jpg"">")
count = regex.Execute(strin).Count
Set regex = Nothing


Response.Write "替换结果:" & result
Response.Write "<br />----------<br />"
Response.Write "表情个数:" & count