日期:2014-05-20  浏览次数:20976 次

如何用正则表达式取的<title></title>之间的内容
1、如何用正则表达式取得 <title> abc </title> 之间的内容, <title> </title> 之间可能有空格之类的,如
<title>
abc
</title>
用 <title> (.*) </title> 这个正则表达式是取不到的

2、如何取得类似baidu,google搜索后内容显示的部分,就是html中的主要内容,而不是从头到尾的取得,把   .style2   {   COLOR:   #666666   }   .style3   {   FONT-WEIGHT:   bold;   FONT-SIZE:   12px   }   .style4   {   FONT-WEIGHT:   bold  
也取到了,

------解决方案--------------------
Regex reg=new Regex( " <title> (.*?) </title> ",RegexOptions.IgnoreCase|RegexOptions.Singleline);
//try
------解决方案--------------------
\ <title[^\> ]*\> \s*(? <Title> .*?)\s*\ </title\>