首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

正规表达式怎么写

2013-04-26 
正规表达式如何写trtd classwwwa href连接1.html连接1/a/td/trtrtd classwwwa

正规表达式如何写
<tr>
<td class="www"><a href="连接1.html">连接1</a>
</td>
</tr>
<tr>
<td class="www"><a href="连接2.html">连接2</a>
</td>
</tr>
请问如何用正规表达式提取  连接1.html  连接1, 连接2.html  连接。这两组文字 正规表达,html
[解决办法]


  string html = @"<tr>
<td class=""www""><a href=""连接1.html"">连接1</a>
</td>
</tr>
<tr>
<td class=""www""><a href=""连接2.html"">连接2</a>
</td>
</tr>";
        foreach (Match m in System.Text.RegularExpressions.Regex.Matches(html, @"(?is)<td[^>]*?class=""www"">\s*<a\s*href=""(?<href>[^""]*?)""[^>]*?>(?<text>.*?)</a>\s*</td>"))
        {

            Console.WriteLine(m.Groups["href"].Value + "\t" + m.Groups["text"].Value);
        }

热点排行