根據正則表達式匹配頁面中js和css文件
阿新 • • 發佈:2019-01-09
regex str ref for mcs group brush ups clas
// 匹配
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文件