码迷,mamicode.com
首页 > Web开发 > 详细

根据正则表达式匹配页面中js和css文件

时间:2019-01-09 12:15:54      阅读:989      评论:0      收藏:0      [点我收藏+]

标签:har   csharp   regex   klist   表达式   ons   foreach   匹配   link   

          // 匹配
          List<string> srcList = new List<string>();
          List<string> linkList = new List<string>();

          // 匹配js文件
                string pattern = "<script[^>]*?src=\"([^>]*?)\"[^>]*?>";
                MatchCollection mcs = Regex.Matches(html, pattern, RegexOptions.IgnoreCase);
                foreach (Match m in mcs)
                {
                    srcList.Add(m.Groups[1].Value);
                }

                // 匹配css
                string patternCss = "<link[^>]*?href=\"([^>]*?)\"[^>]*?>";
                mcs = Regex.Matches(html, patternCss, RegexOptions.IgnoreCase);
                foreach (Match m in mcs)
                {
                    linkList.Add(m.Groups[1].Value);
                }

  

根据正则表达式匹配页面中js和css文件

标签:har   csharp   regex   klist   表达式   ons   foreach   匹配   link   

原文地址:https://www.cnblogs.com/lldbj/p/10243445.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!