Okay, I'm currently trying to create bbcodes for my home made forum. It worked good, until I started with quotes. This is my function:
public function forum_parse ($string)
{
global $core, $path;
$string = $this -> normal_parse ($string);
$search = '/\[quote=([A-z0-9 -_\'"]+);([0-9]+)\](.*)\[\/quote\]/is';
$replace = '<div class="quote"><p class="quote-author"><a href="' . $path . 'forum/viewtopic?p=$2">' . WRITTEN_BY . ' $1</a></p><p class="quote-content">$3</p></div>';
return preg_replace ($search, $replace, $string);
}
It works good when there's one quote per post, but when there's more, the problems begin. It obviously doesn't start from the root quote and choose accurate end tags by itself. And I' not experienced with RegEx enough to fix it. Any help? :/