如何使用正则表达式从c#代码中删除html字符串中的display:none标签 [英] How to remove display: none tags from html string in c# code using regular expressions

查看:294
本文介绍了如何使用正则表达式从c#代码中删除html字符串中的display:none标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用正则表达式从c#代码中的html字符串中删除display:none标签



How to remove display: none tags from html string in c# code using regular expressions

<tr>
<td colspan="6" rowspan="1" style="display: none;">ABC</td>
<td colspan="1" rowspan="2" >BCV</td>
<td colspan="8" rowspan="1" >Date</td>
</tr>

<tr class="headertr" style="color: Black; border-color: Black;">
<td scope="col" style="display: none;">kkfd %</td>
<td scope="col" style="display: none;">fd SR</td>
<td scope="col" style="display: none;">dsd</td>

<td scope="col">Current Year</td>
<td scope="col">Prior Year</td>

</tr>

I want to remove td which has display none property , I need output as below

<tr>

<td colspan="1" rowspan="2" >BCV</td>
<td colspan="8" rowspan="1" >Date</td>
</tr>

<tr class="headertr" style="color: Black; border-color: Black;">

<td scope="col">Current Year</td>
<td scope="col">Prior Year</td>

</tr>

推荐答案

我也喜欢正则表达式,但为什么不使用带字符串的简单if包含?鉴于这个简单的问题,正则表达式似乎极端矫枉过正。
I love regular expressions also, but why not just use a simple if with a string contains? The regex seems like extreme overkill given the simple issue.


这篇关于如何使用正则表达式从c#代码中删除html字符串中的display:none标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆