当前位置: 代码迷 >> ASP >> UBB代码替换有关问题 多谢帮忙
  详细解决方案

UBB代码替换有关问题 多谢帮忙

热度:260   发布时间:2012-06-02 14:16:14.0
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 
  相关解决方案