日期:2014-05-19  浏览次数:20813 次

如何用正则表达替换?
两个问题
我获取一个页面
1,我想得到从 <--title--> ,截至到 <--/title/--> 之间得内容
2,我想把 <dd> ......... </dd> 之间得值获取出来,并且这样的有多个

------解决方案--------------------
1\ string sourceString = @ " <--title--> ,截至到 <--/title/--> ";
string pattern = @ "(? <= <--title--> )([\s\S]+?)(?= <--/title/--> ) ";
System.Text.RegularExpressions.Match result = Regex.Match(sourceString,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase|System.Text.RegularExpressions.RegexOptions.Multiline);

while(result.Success)
{
WL( "正确: " + result.Value);//输出
result = result.NextMatch();
}