I'm using this code {$entry.entry|strip_tags}
to strip tags, however I would just like to strip <p>
tags and not all HTML tags.
Can someone help?
Thank you
I'm using this code {$entry.entry|strip_tags}
to strip tags, however I would just like to strip <p>
tags and not all HTML tags.
Can someone help?
Thank you
If you want to strip ONLY <p>
tags, try a simple regular-expression replacement:
{$entry.entry|regex_replace:"/(<p>|<p [^>]*>|<\\/p>)/":""}
This will replace <p>
, </p>
and all <p many attributes>
strings with an empty string.
Let me know if it works. I tested the regular expression in PHP, not directly in Smarty.
You can do this using the regex_replace modifier:
{$foo = '<p>hello world</p><p some-att="ribute">foo</p>'}
{$foo|regex_replace:'#<\s*/?\s*p(\s[^>]*)?>#i':' '|escape}
To remove the tags and it's contents use
{$content|regex_replace:'/(<(<(p)\b[^>]*>).*?(<\/\2>)/is':''}
to remove more tags simply add |tag Example to remove span and div tags as well
{$content|regex_replace:'/(<(<(p|div|span)\b[^>]*>).*?(<\/\2>)/is':''}
© 2022 - 2025 — McMap. All rights reserved.