下面html需要一次分析出
标题(去html代码):表现良好!马自达3 C-NCAP碰撞实验完成
链接:http://www.autohome.com.cn/news/200802/34367.html
日期:2008-2-26 13:35
来源:汽车之家<span>• <a href=http://www.autohome.com.cn/news/200802/34367.html name="_t" rel="&a=5&pn=1" target=_blank>表现良好!<font color="#C60A00">马自达</font>3 C-NCAP碰撞实验完成</a> <font class=g size=1>汽车之家 2008-2-26 13:35</font><br></span>
标题(去html代码):表现良好!马自达3 C-NCAP碰撞实验完成
链接:http://www.autohome.com.cn/news/200802/34367.html
日期:2008-2-26 13:35
来源:汽车之家<span>• <a href=http://www.autohome.com.cn/news/200802/34367.html name="_t" rel="&a=5&pn=1" target=_blank>表现良好!<font color="#C60A00">马自达</font>3 C-NCAP碰撞实验完成</a> <font class=g size=1>汽车之家 2008-2-26 13:35</font><br></span>
解决方案 »
- 关于My97日历控件的简单问题
- 如何动态的输出到网页上,新手,50分,在线等!
- 关于过期提醒的功能该怎么做?
- 从网页取数据的问题(完全没有思路,大家出出主意)
- 我刚学在VS2008中新建了一个C#项目的ASP.NET Web应用程序,不知道为什么控件托不到Default.aspx窗体上。多次新建立都不行,但找到一个小例子却可以托上去。
- 求多表联查绑定到DataGrid的代码
- 怎样用asp.net+sql存储过程写的搜索程序
- 找开任何ASP.NET文件出现以下错误,怎么解决
- 一个窗体验证的问题,很奇怪,不知道是怎样开发的
- 高分求救vb类型转换的问题???高手帮忙!
- 大侠救命!Gridview导出EXCLE表出现乱码~
- Image1.ImageUrl 如何动态加载图片
(?<=href=)http.*?\s|(?<=>)[^&]*?(?=<)
匹配结果http://www.autohome.com.cn/news/200802/34367.html
表现良好!
马自达
3 C-NCAP碰撞实验完成
汽车之家 2008-2-26 13:35
<a href=(?<urlText>)\S+[\s\S]+?>(?<title1>)[^>]+<font[^>]+>(?<title2>)[^>]+</font>(?<title3>)[^>]+</a>([\S]+)?<font[^>]+>((?<sourceText>)\W+)((?<time>)\S+\s+[\S]+)(?=</font>)
MatchCollection matchCollection = Regex.Matches( strInput, strReg, RegexOptions.Multiline );
foreach ( Match ma in matchCollection )
{
Console.WriteLine( "链接:" + ma.Groups["url"] );
Console.WriteLine( "标题:"+ ma.Groups["title1"].Value + ma.Groups["title2"].Value + ma.Groups["title3"].Value );
Console.WriteLine("来源:"+ ma.Groups["source"] );
Console.WriteLine( "日期:"+ma.Groups["time"]);
} 好久没写了..
string text=".....";
string regMath = @"<a href=(?<urlText>)\S+[\s\S]+?>(?<title1>)[^>]+<font[^>]+>(?<title2>)[^>]+</font>(?<title3>)[^>]+</a>([\S]+)?<font[^>]+>((? <sourceText>)\W+)((?<time>)\S+\s+[\S]+)(?=\\<\\/font\\>)";
Match mc = Regex.Match(text, regMath);
if (mc.Success)
{
string title=mc.group["title1"].ToString()+mc.group["title2"].ToString()+mc.group["title3"].ToString();
string link=mc.group["urlText"].ToString();
string source=mc.group["sourceText"].ToString();
string time=mc.group["time"].ToString();
}
正在分析“<a href=(?<urlText>)\S+[\s\S]+?>(?<title1>)[^>]+<font[^>]+>(?<title2>)[^>]+</font>(?<title3>)[^>]+</a>([\S]+)?<font[^>]+>((? <sourceText>)\W+)((?<time>)\S+\s+[\S]+)(?=\\<\\/font\\>)”- 无法识别的分组构造。
如果你要处理的数据格式是形如你给出的示例字符串,是可以正确匹配出的
如果有出入还请搂主指出