日期:2014-05-16 浏览次数:20769 次
var str="{a},你好!今天是{b}";
str =str.replace(/(\{)([^\}]+)(\})/ig,function (key) {
console.log(arguments);
return key;
});
s="[最新贴吧_随机_随机]"
set re = new regexp
re.Pattern = "最新贴吧_(.)+_(.)+"
msgbox re.replace(s, "function($1,$2)")
Function fun(a,b)
fun="{最新贴吧:}传入的值分别是a="&a&" b="&b
End function
Dim html,n,i,ii,re
html="这是CMS常用模板引擎方法,建议使用{$article(2,3)}的形式<br/><p>其他html</p>[最新贴吧_(1)_(2)]<div>说明:参数里不建议有(),因为数字需要作参数传给函数[最新贴吧_(10)_(20)]</div>"
Set re=new RegExp
re.IgnoreCase=True
re.Global=True
re.Pattern = "\[最新贴吧_\((\d+)\)_\((\d+)\)\]"
Set ii = re.Execute(html)
If ii.count>0 Then '如果匹配到有
For Each i In ii
html=Replace(html,i.Value,fun(i.SubMatches(0),i.SubMatches(1)))
Next
End If
set re=Nothing
Response.write html
re.Pattern = "\[最新贴吧_(\d+)_(\d+)\]"