Strip bbcode and contents

Naz

XenForo developer
Staff member
What would be the best way to strip BBCode and their contents from a string?

Thanks.
 
I use this in my add-on:
PHP:
$content = XenForo_Helper_String::bbCodeStrip($thread['message']);
$content = preg_replace('/\[(attach|media|img|spoiler)\]/siU', '', $content);
$content = preg_replace('/^[\t\s]*(\r?\n){2,}/m', '', $content);
 
I use this in my add-on:
PHP:
$content = XenForo_Helper_String::bbCodeStrip($thread['message']);
$content = preg_replace('/\[(attach|media|img|spoiler)\]/siU', '', $content);
$content = preg_replace('/^[\t\s]*(\r?\n){2,}/m', '', $content);
Perfect, thanks Brogan. :love:
 
PHP:
\XF::app()->stringFormatter()->stripBbCode('...');
Thank you @Jeremy P
Is there a list of the available stringFormatter functions?

EDIT:
I found the relevant class: src\XF\Str\Formatter.php
But is there a list that explains what each option does?
 
Last edited:
Top Bottom