日期:2014-05-17 浏览次数:20864 次
StreamReader reader = new StreamReader("e:\\1.txt",Encoding.Default); string content = reader.ReadToEnd() ; Regex reg = new Regex(@"(?is)(?<=<div class=""ft_d_filename"">)[^>]*?(?=</div>)|(?<=<span class=""ft_d_fileSize"">)[^>]*?(?=</span>)|(?<=<a[^>]*?href="")[^>]*?(?="")"); MatchCollection ms = reg.Matches(content); foreach (Match m in ms) { MessageBox.Show(m.Value); }
------解决方案--------------------
1.(?i)<div[^>]*?class=(['""]?)ft_d_filename\1[^>]*?>(?<name>[^<>]*?)</div>
取m.Groups["name"].Value
2.(?i)<span[^>]*?class=(['""]?)ft_d_fileSize\1[^>]*?>(?<size>[^<>]*?)</span> 去分组size
3.(?i)<a[^>]*?class=(['""]?)ft_d_btnDownload\s*?btn_blue\1[^>]*?href=(['""]?)(?<href>[^'""]*?)\2[^>]*?>[^>]*?</a> 去分组href
------解决方案--------------------
<div class="ft_d_filename">(.*?)</div>\s*<span class="ft_d_fileSize">(.*?)</span>\s*<a un="down" class="ft_d_btnDownload btn_blue" href="(.*?)"[^>]*>
------解决方案--------------------
第一个:
(?<=<div class="ft_d_filename">)(?:(?!</div).)+
第二个:
(?<=<span class="ft_d_fileSize">)(?:(?!</span).)+
第三个:
(?<=<a un="down" class="ft_d_btnDownload btn_blue" href=")[^"]+
------解决方案--------------------
第一个:
(?<=<div class="ft_d_filename">)(?:(?!</div).)+
第二个:
(?<=<span class="ft_d_fileSize">)(?:(?!</span).)+
第三个:
(?<=<a un="down" class="ft_d_btnDownload btn_blue" href=")[^"]+