正规表达式如何写
<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);
}