How to strip bbcode from text

Discussion forum for Extension Writers regarding Extension Development.
User avatar
Tarantino
Registered User
Posts: 658
Joined: Sat Feb 18, 2012 1:51 pm
Contact:

Re: How to strip bbcode from text

Post by Tarantino » Mon Jan 22, 2018 10:14 am

JoshyPHP wrote:
Tue Jun 06, 2017 5:39 pm
Here's what I ran:

Code: Select all

$text = '<r><B><s>[b]</s>bold<e>[/b]</e></B> :lol: http://google.com</r>';
strip_bbcode($text);
die($text);
Here's what I got:

Code: Select all

 bold  :lol: http://google.com
Does it work differently for you?
Hi there, I saw a problem today and saw here on your example the same problem. strip_bbcode adds a space when removing bbcode.
So if we've: Some text with bold. Text
It will become: Some text with bold . Text

And we don't want that extra space :/

User avatar
JoshyPHP
Code Contributor
Posts: 948
Joined: Mon Jul 11, 2011 12:28 am

Re: How to strip bbcode from text

Post by JoshyPHP » Mon Jan 22, 2018 11:49 pm

There's nothing in phpBB that does that specifically. For messages posted on 3.2, you can remove most formatting with s9e\TextFormatter\Utils::removeFormatting($xml). That's what strip_bbcode() uses via clean_formatting().
I wrote the thing that does BBCodes in 3.2.

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests