gpt4 book ai didi

html - 正则表达式替换几个html属性

转载 作者:太空宇宙 更新时间:2023-11-04 14:47:59 29 4
gpt4 key购买 nike

我有这个 html:

<table style="width: 128px;" border="0" cellspacing="0" cellpadding="0">
<colgroup span="1"><col span="2" width="64"></col></colgroup>
<tbody>
<tr height="20">
<td width="64" height="20">&nbsp;</td>
<td class="xl65" dir="rtl" width="64"><strong></strong></td>
</tr>
<tr height="20">
<td class="xl67" dir="rtl" width="64" height="20">&nbsp;</td>
<td class="xl66" dir="ltr" width="64">T3500&nbsp;</td>
</tr>
<tr height="20">
<td class="xl68" width="64" height="20">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr height="20">
<td height="20">&nbsp;</td>
<td class="xl65" dir="rtl" width="64"><strong></strong></td>
</tr>
<tr height="48">
<td class="xl67" dir="rtl" width="64" height="48">&nbsp;</td>
<td class="xl66" dir="ltr" width="64">Intel&reg; X58 Chipset&nbsp;</td>
</tr>
<tr height="33">
<td class="xl70" dir="rtl" width="64" height="33">&nbsp;</td>
<td class="xl69" dir="ltr" width="64">10/100/1000&nbsp;</td>
</tr>
<tr height="20">
<td class="xl68" width="64" height="20">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr height="20">
<td height="20">&nbsp;</td>
<td class="xl65" dir="rtl" width="64"><strong></strong></td>
</tr>
<tr height="96">
<td class="xl67" dir="rtl" width="64" height="96">&nbsp;</td>
<td class="xl66" dir="ltr" width="64">One Intel Xeon W3503(2.4GHz,4.8GT/s,4MB,DC)&nbsp;</td>
</tr>
<tr height="20">
<td class="xl68" width="64" height="20">&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>

我想用任何东西替换所有样式、目录、高度、宽度和类,这样它就会被删除

这是我为其中一些尝试过的方法,它在在线测试器中有效,但在 Notepad++ 中无效

( class=\"([^\"]*)\"){0,} (width=\"([^\"]*)\"){0,} (height=\"([^\"]*)\"){0,}

最佳答案

尝试

\s*(?:style|dir|height|width|class)\s*=\s*"[^"]*"\s*

当然,这将删除像 style="hello" 这样的文本,无论它们出现在哪里,也包括在标签之外。

可能是Notepad++不支持\s简写。尝试使用

[ ]*(?:style|dir|height|width|class) *= *"[^"]*" *

相反,看看是否可行。开头的[ ]可以用一个空格代替。

关于html - 正则表达式替换几个html属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4612779/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com