I have a problem with BBCodes - this preg_replace does not work as intended:
$message = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\](.*)\[\/color\]/Usi", "<span style=\"color:\\1\">\\2</span>", $message);
This works correctly:
[color=#ff0000]text text text text text[/color]
[color=#00ffff]texttexttext[/color]
Result:
But if there are two color tags one after another, it does not work correctly:
[color=#ff0000][color=#00ffff]text text text text text[/color] [/color]
[color=#ff0000]text text text[color=#00ffff]text text text text text[/color] [/color]
Result:


preg_replace(['~\[color=(#[0-9A-F]+)\]~i', '~\[/color\]~i'], ['<span style="color: $1">', '</span>'], $str);- bobble bubble