// 匹配
??????????? 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文件
原文地址:https://www.cnblogs.com/lldbj/p/10243445.html