// colours
$text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+):$uid\]/si", $bbcode_tpl['color_open'], $text);
$text = str_replace("[/color:$uid]", $bbcode_tpl['color_close'], $text);
// size
$text = preg_replace("/\[size=([1-2]?[0-9]):$uid\]/si", $bbcode_tpl['size_open'], $text);
$text = str_replace("[/size:$uid]", $bbcode_tpl['size_close'], $text);
//
and for bolding text.
$text = str_replace("[b:$uid]", $bbcode_tpl['b_open'], $text);
$text = str_replace("[/b:$uid]", $bbcode_tpl['b_close'], $text);
//
and for underlining text.
$text = str_replace("[u:$uid]", $bbcode_tpl['u_open'], $text);
$text = str_replace("[/u:$uid]", $bbcode_tpl['u_close'], $text);
//
and for italicizing text.
$text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
$text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);
// Patterns and replacements for URL and email tags..
$patterns = array();
$replacements = array();
// [img]image_url_here[/img] code..
// This one gets first-passed..
$patterns[] = "#\[img:$uid\](.*?)\[/img:$uid\]#si";
$replacements[] = $bbcode_tpl['img'];
// matches a [url]xxxx://
www.phpbb.com[/url] code..
$patterns[] = "#\[url\\]([\w]+?://[^ \"
\t<]*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url1'];
270> //
http://www.phpbb.com code.. (no xxxx:// prefix).
$patterns[] = "#\[url\]((www|ftp)\.[^ \"
\t<]*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url2'];
// [url=xxxx://
www.phpbb.com]phpBB[/url] code..
$patterns[] = "#\
+?://[^ \"
\t<]*?)\](.*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url3'];
// [url=http://www.phpbb.com]phpBB code.. (no xxxx:// prefix).
$patterns[] = "#\[url=((www|ftp)\.[^ \"
\t<]*?)\](.*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url4'];
//
user@domain.tld code..
$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@