<a href="download.aspx">1</a><a href="http://www.baidu.com/download.aspx">2</a><a href="/download.aspx">如上代码,我想仅仅只匹配download.aspx出来,凡是带http开头或者说带有"/"的均不匹配,请问该如何写此表达式呢?还望高手多多赐招。很困扰啊。
解决方案 »
- 一段扫描端口的代码,希望高人帮我改一个小bug
- 自定义控件添加事件
- Winform标题栏放contextmenustrip的问题
- 文件夹中内容的查找!!!!!!!!!!!!
- 一个工程中windows form的执行顺序
- 字符串转换为日期的问题!!!
- 如何从SQL中读取数据(用于发送短信平台短信)
- 求字符串的格式修改!!!!
- 如何在C#中调用多参数(全部是Input,两个以上)的存储过程?急!!
- c#编程数据库访问时,登陆界面登陆成功后如何把登录人的信息在另一窗体显示出来,实现窗体传送
- C# 反编译出来的winform文件拆分
- 64位的win2003 配置iis运行asp.net 4路由 ,设置
MatchCollection matches = Regex.Matches(s, @"(?is)<a\s+href=""[^./]+\.[^./]+"">.*?</a>");
foreach (Match match in matches)
Response.Write(match.Value + "<br/>");
MatchCollection matches = Regex.Matches(s, @"(?is)(?:href|src)=(['""])(?<地址>[^./]+\.[^./]+)\1");
foreach (Match match in matches)
Response.Write(match.Groups["地址"].Value + "<br/>");
download.aspx
a.jpgGroups["地址"]是名为“地址”的正则捕获组。
string s = @"<a href=""download.aspx"">1</a><a href=""http://www.baidu.com/download.aspx"">2</a><a href=""/download.aspx""><img src='a/a.jpg' /><a href='/p.html'></a>";
MatchCollection matches = Regex.Matches(s, @"(?is)(?:href|src)=(['""])(?!href|/)(?<地址>[^.]+\.[^./]+)\1");
foreach (Match match in matches)
Response.Write(match.Groups["地址"].Value + "<br/>");
download.aspx
a/a.jpg
比如原来是<a href="download.aspx" target="_blank" style="color:#FFF; text-decoration:none;">的东西,结果却错误的取出 download.aspx" target="_blank" style="color:#FFF; text-decoration:none; 能再完美下吗?也就是取到最后一个引号内的东西了,中途有引号的计算在内了
试试。
样式中的路径如何也能取掉呢。
这种情况会错误的匹配,请问如果改动能排除忽略这个