日期:2014-05-18 浏览次数:20892 次
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>"
就行了。