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

这个是<%=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); 
posted @ 2008-06-23 10:24  非♀闪  阅读(438)  评论(0编辑  收藏  举报