我的bb代码有问题。我有一个函数,它将bbcode替换为php代码
public static function decodeBB($text)
{
$text = nl2br($text);
$text = preg_replace('/\[b\](.*)\[\/b\]/Usi', '<b>$1</b>', $text);
$text = preg_replace('/\[i\](.*)\[\/i\]/Usi', '<i>$1</i>', $text);
$text = preg_replace('/\[s\](.*)\[\/s\]/Usi', '<s>$1</s>', $text);
$text = preg_replace('/\[u\](.*)\[\/u\]/Usi', '<u>$1</u>', $text);
$text = preg_replace('/\[quote\](.*)\[\/quote\]/Usi', '<div>Quote:</div><span style=\"border:solid 1px;background-color: white;\">$1</span>', $text);
$text = preg_replace("/\[url=(?:'|"|\'|\")(((ht|f)tps?:(?:\/\/)?)(?:[^<\s\'\"]+))(?:'|"|\'|\")\](.*)\[\/url\]/Usi", "<a href=\"$1\">$4</a>", $text);
$text = preg_replace("/\[img\](((ht|f)tps?:(?:\/\/)?)(?:[^<\s\'\"]+))\[\/img\]/Usi", "<img src=\"$1\">", $text);
$text = preg_replace("/(?<!:'|"|\'|\"|\])(((ht|f)tp(s)?:\/\/)([^<\s\'\"]+))(?<!:'|"|\'|\"|\[)/is", "<a href=\"$1\">$1</a>", $text);
$text = self::BBquote($text);
return $text;
}
当文字写成这样的时候,[quote] [/ quote]有问题:
[quote]Hello[/quote]
这样可行,但是当它写成这样的时候它不起作用:
[quote][quote]Hello[/quote]How are you?[/quote]
但是其他代码工作正常,有人知道如何解决这个问题吗?