Naz XenForo developer Staff member Aug 15, 2014 #1 What would be the best way to strip BBCode and their contents from a string? Thanks.
P Paul B XenForo moderator Staff member Aug 15, 2014 #2 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);
Naz XenForo developer Staff member Aug 15, 2014 #3 Brogan said: 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); Click to expand... Perfect, thanks Brogan.
Brogan said: 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); Click to expand... Perfect, thanks Brogan.
fahad ashraf Well-known member Apr 15, 2021 #4 Brogan said: $content = XenForo_Helper_String::bbCodeStrip($thread['message']); Click to expand... @Brogan please let me know its alternate function on xenforo 2 ??
Brogan said: $content = XenForo_Helper_String::bbCodeStrip($thread['message']); Click to expand... @Brogan please let me know its alternate function on xenforo 2 ??
Jeremy P XenForo developer Staff member Apr 15, 2021 #5 PHP: \XF::app()->stringFormatter()->stripBbCode('...');
Orit Active member Feb 28, 2024 #6 Jeremy P said: PHP: \XF::app()->stringFormatter()->stripBbCode('...'); Click to expand... 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: Feb 28, 2024
Jeremy P said: PHP: \XF::app()->stringFormatter()->stripBbCode('...'); Click to expand... 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?