原文:<a href="http://www.wywan.com" >aaa1</a><a href="http://www.dnfclub.com" >aaa2</a><a href="http://www.97bet.com" >aaaa3</a><a href="http://www.hao123.com" >hao123</a>
要求提取除了www.dnfclub.com 之外的所有超链接 格式为www.97bet.com
要求提取除了www.dnfclub.com 之外的所有超链接 格式为www.97bet.com
解决方案 »
- 水晶报表分组后,怎样统计每组的记录总数
- Client unable to establish Connection
- 吐血奉献:C#获取硬盘编号、CPU编号及类型、内存大小及使用情况
- 高手请看—水晶报表的问题
- 说了你们也不会信,,在MDI的子窗体中的 Maximinzebox =false ,运行后,看起来是灰色的,不能点,,但点击后,就变成Normal的窗体了,?
- c结构体包含回调函数在c#中怎样引用
- DevExpress.XtraNavBar的问题~~,急!谢谢
- c#调用VC中不安全代码的问题。请高人指点!急用!!!
- 求一int类型的正则表达式??最好告诉怎使用??谢谢拉
- 关于System.Diagnostics.Process.Start
- 控件 ComboBox 应用时 求问题解决!
- 求C#CHM帮助文档
帮下忙啊 谢谢了
MatchCollection mc=Regex.Matches(input,@"(?is)<a\s*href=""https?://www.[^dnfclub]+.[^""]+""[^>]*>.*?</a>");
froeach(Match m in mc)
{
Console.WriteLine(m.Value);
}
改一下string input=@"<a href=""http://www.wywan.com"" >aaa1</a><a href=""http://www.dnfclub.com"" >aaa2</a><a href=""http://www.97bet.com"" >aaaa3</a><a href=""http://www.hao123.com"" >hao123</a>";
MatchCollection mc=Regex.Matches(input,@"(?is)<a\s*href=""https?://www.[^dnfclub]+.[^""]+""[^>]*>.*?</a>");
froeach(Match m in mc)
{
Console.WriteLine(m.Value);
}
[^dnfclub]这个是排除型字符组不是单词
{
string bdurl = "http://" + url;
string bdcontent =@getHtml(bdurl, "");
MatchCollection mc=Regex.Matches(bdcontent,@"(?is)<a\s*href=""https?://www.[^97bet]+.[^""]+""[^>]*>.*?</a>"); foreach (Match m in mc)
{
MessageBox.Show(m.Value);
} return mc.Count;
}不知道为什么 提取不出啦 C#新手 帮忙看下
MatchCollection mcReg = Regex.Matches(input, @"(?is)<a\s*href=""https?://www.(?!(dnfclub))+.[^""]+""[^>]*>.*?</a>");
foreach (Match m in mcReg)
{
Console.WriteLine(m.Value);
}
为什么获取不到匹配内容
现在提取到的是包含<a href这些的
string input = @"<a href=""http://www.wywan.com"" >aaa1</a><a href=""http://www.dnfclub.com"" >aaa2</a><a href=""http://www.97bet.com"" >aaaa3</a><a href=""http://www.hao123.com"" >hao123</a><a href=""http://www.dnfclu.com"" >aaa4</a>";
MatchCollection mcReg = Regex.Matches(input, @"(?is)<a\s*href=""(https?://www.(?!(dnfclub))+.[^""]+)""[^>]*>.*?</a>");
foreach (Match m in mcReg)
{
Console.WriteLine(m.Groups[1].Value);
}
就是说有这3种可能
<a href="http://..
<a href='http://
<a href=http://
MatchCollection mcReg = Regex.Matches(input, @"(?is)<a\s*href=[""']*(https?://www.(?!(dnfclub))+.[^""']+)[""']*[^>]*>.*?</a>");