<p><strong><a href="http://www.xxx.com">某某公司</a></strong></p>如何用正则代码
获取href连接[http://www.xxx.com]
获取a标签文本[某某公司] 语言.NET 快速解决立马结贴
获取href连接[http://www.xxx.com]
获取a标签文本[某某公司] 语言.NET 快速解决立马结贴
解决方案 »
- c# datagridview 逐条验证数据
- 关于用UpdatePanel取不到值的问题
- 高分求助:当员工生日时在首页上显示祝贺,怎么设计比较合理?
- 总技术分排名:4444,散分驱悔气....
- 关于Microsoft Visual Studio .NET 2003问题
- RE: 趣味题:__*_=___=_*__ (备注:其中"_"为一个数字,数字为1-9,但不能重复) 用程序写出结果
- 再发,计算DataGrid某一列的总和!
- 求救:如何在页面中禁止用户访问<select>控件??在线等待!
- 大家帮帮忙,非常奇怪的现象~!
- 如何格式化输出Gridview中的字符串?
- img无法读取本地路径图片
- 字符串问题
Regex regex = new Regex(@"<a\s+href=""(?<href>[^""]+)"">(?<value>[^<]+)</a>");
MatchCollection collection = regex.Matches(input);
foreach (Match item in collection)
{
Console.WriteLine("href={0} value={1}", item.Groups["href"].Value, item.Groups["value"].Value);
}
string input = @"<p><strong><a href=""http://www.xxx.com"">某某公司</a></strong></p>";
var first = Regex.Matches(input, @"<a.*?href=[""']([^""']+)[^>]+>([^<]+)</a>").Cast<Match>().Select(t => new { href = t.Groups[1].Value, txt = t.Groups[2].Value }).ToArray();