c# 简单正则表达式求助!!!!!!!!!!!!!!!!!!
<td class="t"><a href="http://www.163.com/10371956236680x.shtml" target="_blank" class="t" >南实小六中学区房转让</a><span class='ico biz'>(个人)</span>
=================================================
这样写不行呢,谁能帮改改
string reg = @"<td class=""t""><a href=""(?<href>.*?)"" target=""_blank"" class=""t"" >(?<title>.*?)</a><span class='ico biz'>(个人)</span>";
这样为什么娶不到!!
[解决办法]
string str = "<td class=\"t\"><a href=\"http://www.163.com/10371956236680x.shtml\" target=\"_blank\" class=\"t\" >南实小六中学区房转让</a><span class='ico biz'>(个人)</span>"; Regex reg = new Regex(@"<td class=""t""><a href=""(?<href>.*?)"" target=""_blank"" class=""t"" >(?<title>.*?)</a><span class='ico biz'>\(个人\)</span>"); Match m = reg.Match(str); Console.WriteLine(m.Groups["href"].Value + "==" + m.Groups["title"].Value);
[解决办法]
(个人),()当成普通字符需要转义的,改成:
@"<td class=""t""><a href=""(?<href>.*?)"" target=""_blank"" class=""t"" >(?<title>.*?)</a><span class='ico biz'>\(个人\)</span>"
就行了。