过滤资源地址

 string strPatten = "(src|href)=(.*?)[>| ]"; 
        string strContent = "<img src=\"http://su.bdimg.com/static/superplus/img/loading_deadaef0.gif\" ><script src='http://s1.bdstatic.com/r/www/cache/static/global/js/all_async_d47e7b7d.js'></script>  <link href=\"/assets/sh-2bfcf65754f6d04d58df6ed87a3b6faf.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />";
        Regex reg = new Regex(strPatten);
        foreach (Match match in reg.Matches(strContent))
        {
            for (int i = 0; i < match.Groups.Count; i++)
            {
                Response.Write(i + ":" + match.Groups[i].Value + "<br>");
            }
        }
        Response.Write("成功!<br>");
        Response.End();

 

posted @ 2014-05-13 13:25  xyzhuzhou  阅读(266)  评论(0编辑  收藏  举报