现在的位置: 首页 > 综合 > 正文

c#使用正则提取内容(例)

2012年06月27日 ⁄ 综合 ⁄ 共 779字 ⁄ 字号 评论关闭

这个是<%=DB.shownewsfunction(2,0,1,14,0,20,200,100,0,1,0,1401,0,0,0,0,0,0)%>这个是<%=DB.shownewsfunction1(2,0,1,14,0,20,200,100,0,1,0,1401,0,0,0,0,0,0)%>

我要提取上面代码中<%=DB.shownewsfunction(2,0,1,14,0,20,200,100,0,1,0,1401,0,0,0,0,0,0)%>,2,0,1,14,0,20,200,100,0,1,0,1401,0,0,0,0,0,0以及shownewsfunction这几个内容,请问怎么做

PS:可能内容中有<%=DB.shownewsfunction1(2,0,1,14,0,20,200,100,0,1,0,1401,0,0,0,0,0,0)%>,<%=DB.shownewsfunction2(2,0,1,14,0,20,200,100,0,1,0,1401,0,0,0,0,0,0)%>等不同的函数,我都要提取

string txt = "<%=DB.shownewsfunction1(2,0,1,14,0,20,200,100,0,1,0,1401,0,0,0,0,0,0)%>"
Regex regex 
= new Regex("<%=DB[.](?<fun>[\\w]+)\\((?<parms>[^\\)]+)\\)%>"); 
Match match 
= regex.Match(txt); 
if (match.Success) 

    Response.Write(match.Groups[
"fun"].Value); 
    Response.Write(match.Groups[
"parms"].Value); 
【上篇】
【下篇】

抱歉!评论已关闭.