简体   繁体   中英

Remove empty html tags with smarty

I want to remove all empty tags. Here's the regex which I've found here but it seems not to work in smarty.

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

The regex should be:

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

The # was missing as @user2182349 mentioned.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM