求一简单正则! 我想批配 /12/aaa_2.html 以下是我写的正则,批配不上,求朋友帮忙,谢谢!^\/(\d{2,4})\/\b(aaa|xxx|ccc|ddd|eee)\b_(\d{1,2})\.html$ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string inputs = "/12/aaa_2.html"; string patterns =@"(?<=/)([\d]{2}/[\w\S\d]{5})(?=.html)"; bool bols = Regex.Match(inputs, patterns).Success; Console.WriteLine(bols); <li><a href="http://www.itravelqq.com/2011/0407/126739.html">四五月成高端蜜月游旺季私密</a> <i>[04-0708:41]</i></li><li><a href="http://www.itravelqq.com/2011/0407/126730.html">去年10万客赴西</a><i>[04-0708:34]</i></li><li>我只想取出herf里的值,标题,与日期 要怎么写啊? string pattern = "(?<=.html>)(.*?)(?=</a>)"; MatchCollection matches = Regex.Matches(input, pattern); foreach (Match match in matches) { Console.WriteLine( match.Groups[1].Value); } 我用Regex Tester做测试Regex处填加的是:^\/(\d{2,4})\/\b(aaa|bbb|ccc)\b_(\d{1,2})\.html$Source处填加的是: /12/aaa_2.html或/12/bbb_2.html或/12/ccc_2.html可是不能正常批配 string pattern = "(?<=.html\>)(.*?)(?=</a>)";上面马虎了,这个才对头 \/\d{2,4}\/(aaa|bbb|ccc)_\d{1,2}\.html 我用 ^\/(\d{2,4})\/\b(aaa|xxx|ccc|ddd|eee)\b\.html$批配 /12/aaa.html或/12/xxx.html 就行为什么^\/(\d{2,4})\/\b(aaa|xxx|ccc|ddd|eee)\b_(\d{1,2})\.html$就不能批配/12/aaa_2.html或/12/xxx_2.html \b是\w和\W的边界,不是文本和非文本的边界。 提取html中的tr和td的正则表达式,或者方法。求代码 20分,一个问题 c#怎么用有参的构造方法调用无参的构造方法? 微软.NET软件工程师实战培训 好不好》 请问没有C语言基础,如何学习C# 如何TreeView的展开事件中获得展开节点的信息,高手请进啊,up有分 获取局域网内所有在线用户名 datatable 逐行添加数据 自定义类用CopyTo方法的疑问 窗体关闭? web servise的状态保持 WPF用C#显示软件正常运行时间
string patterns =@"(?<=/)([\d]{2}/[\w\S\d]{5})(?=.html)";
bool bols = Regex.Match(inputs, patterns).Success;
Console.WriteLine(bols);
string pattern = "(?<=.html>)(.*?)(?=</a>)";
MatchCollection matches = Regex.Matches(input, pattern);
foreach (Match match in matches)
{
Console.WriteLine( match.Groups[1].Value);
}
Regex处填加的是:^\/(\d{2,4})\/\b(aaa|bbb|ccc)\b_(\d{1,2})\.html$
Source处填加的是: /12/aaa_2.html或/12/bbb_2.html或/12/ccc_2.html可是不能正常批配
批配 /12/aaa.html或/12/xxx.html 就行为什么
^\/(\d{2,4})\/\b(aaa|xxx|ccc|ddd|eee)\b_(\d{1,2})\.html$
就不能批配/12/aaa_2.html或/12/xxx_2.html