当前位置: 代码迷 >> ASP.NET >> 正则 The Regulator 有关问题
  详细解决方案

正则 The Regulator 有关问题

热度:5998   发布时间:2013-02-25 00:00:00.0
正则 The Regulator 问题
http://community.csdn.net/Expert/topic/5537/5537954.xml?temp=.9923517
请这边看

------解决方案--------------------------------------------------------
转义不正确造成的,前面加@时“ "”用“ " "”进行转义,而不是“\ "”,如果不加@,那么“\s”这样的要用“\\s”进行转义,统一一下就行了,如下,测试通过

MatchCollection mc = Regex.Matches(yourStr, @ " <td\snowrap\swidth= " "12% " "\sclass= " "caption " "> ([\w-\W]*?) </td> [\w-\W]{5,20} <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "\sbgcolor= " "[#]e7e7e7 " "> ([\w-\W]*?) </td> [\w-\W]{5,7} <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "\s> ([\w-\W]*?) </td> [\w-\W]{5,7} <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "\sbgcolor= " "[#]e7e7e7 " "> ([\w-\W]*?) </td> [\w-\W]*? <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "> ([\w-\W]*?) </td> [\w-\W]*? <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "\sbgcolor= " "[#]e7e7e7 " "> ([\w-\W]*?) </td> [\w-\W]*? <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "> ([\w-\W]*?) </td> [\w-\W]*? <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "\sbgcolor= " "[#]e7e7e7 " "> ([\w-\W]*?) </td> [\w-\W]*? <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "> ([\w-\W]*?) </td> [\w-\W]*? <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "\sbgcolor= " "[#]e7e7e7 " "> ([\w-\W]*?) </td> [\w-\W]*? <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "> ([\w-\W]*?) </td> [\w-\W]*? <td\salign= " "right " "\swidth= " "8% " "\snowrap\sclass= " "copy " "\sbgcolor= " "[#]e7e7e7 " "> ([\w-\W]*?) </td> ", RegexOptions.IgnoreCase);