BBCode parser without regex?

I am looking for a BBCode parser in Javascript or PHP without the need for Regex. Can anyone suggest me a good one?

+5
source share
6 answers

Regular expression recommended.

Another solution:

function bb_parse($str)
{
    return str_replace(array('[b]', '[/b]'), array('<strong>', '</strong>'), $str);
}

This can lead to parsing due to incorrectly closing tags, resulting in the content being terminated by the HTML tag without closing.

+6
source

There is a PECL extension for bbcode . You will need to take a look at how to install the PECL extensions to use it.

+2
source

Zend parser , http://framework.zend.com/manual/en/zend.markup.parsers.html

, BBCode, : ([b] asdf [/ wops I forgot to close my tag), . bbcode , .

+1

I recently wrote a bbcode parser in javascript.

What can he do:

  • Convert BBcode string to HTML string;
  • Convert an HTML element to a BBCode string;
  • Auto-adjust BBCode string;

Check out the demo: UBBParser

0
source

If you can install the PECL extension, you can use the BBCode functions

-1
source

All Articles