正则表达式(mtracer)
<div>
<a href= "http://www.baidu.com " title= 'baidu '> www.baidu.com </a>
</div>
<a href= "http://www.sina.com.cn " title= 'sina '> www.sina.com.cn </a>
我需要取的数据如下:
是div之间的。
http://www.baidu.com
baidu
www.baidu.com
------解决方案--------------------using System.Text.RegularExpressions;
string str = " <div> <a href=\ "http://www.baidu.com\ " title= 'baidu '> www.baidu.com </a> </div> ";
string link = Regex.Match(str, "href=\ "([^]]+)\ " title ").ToString();
link = Regex.Replace(link, "(href=\ ")|(\ " title) ", " ");
string title = Regex.Match(str, "title= '([^]]+) '> ").ToString();
title = Regex.Replace(title, "(title= ')|( '> ) ", " ");
string size = Regex.Match(str, " '> ([^]]+) </a> ").ToString();
size = Regex.Replace(size, "( '> )|( </a> ) ", " ");
//验证通过~~~