C# 获取内部价值观<;td>;标签
可变HTML标记:C# 获取内部价值观<;td>;标签,c#,html,regex,C#,Html,Regex,可变HTML标记: <td class="center line"><strong>Banana</strong></td> <td class="center line red"><strong>(Apple)</strong></td> <td class="center">Orange</td> <td class="center red">Cherry<
<td class="center line"><strong>Banana</strong></td>
<td class="center line red"><strong>(Apple)</strong></td>
<td class="center">Orange</td>
<td class="center red">Cherry</td>
香蕉
(苹果)
橙色
樱桃
这是行不通的
<td class=\"center[ line]?[ red]?\">[<strong>]?[(]?[A-Za-z]*[)]?[</strong>]?</td>
[]?[(]?[A-Za-z]*[)]?[]?
行、红色、强标记为常量
救命啊 您可以尝试使用下面的正则表达式来匹配上述四行
<td\s*class=\"center(?: line(?: red)?| red)?\">(?:<strong>)?\(?[A-Za-z0-9]*\)?(?:<\/strong>)?<\/td>
(?:)?\(?[A-Za-z0-9]*\)(?:)?
使用非捕获组或捕获组而不是
[line]?
将行作为可选行。它可能是(行)
或(?:行)
使用(行)
,(红色)
等。相反,使用XML解析器。