使用smarty删除空的html标签


Remove empty html tags with smarty

我想删除所有空标签。这是我在这里找到的正则表达式,但它似乎在 smarty 中不起作用。

regex_replace:"#<p[^>]*>('s|&nbsp;|</?'s?br's?/?>)*</?p>#":"";
regex_replace:"<('w+)'s*.*?>'s*?</'1>#":"";
regex_replace:"<[^>]*>'s*<'/[^>]*>#":"";

正则表达式应该是:

regex_replace:"#<p[^>]*>('s|&nbsp;|</?'s?br's?/?>)*</?p>#":"";
regex_replace:"#<('w+)'s*.*?>'s*?</'1>#":"";
regex_replace:"#<[^>]*>'s*<'/[^>]*>#":"";

正如@user2182349提到的,#失踪了。