hi,
I know what u mean, kind of... I do it like this :
$str contains your message...
first, do this:
$str = nl2br(htmlspecialchars($str))
then, you can do stuff like this:
$str = eregi_replace("\[b\](.*)\[/b\]","< b >\1< /b >",$str);
leave out the spaces in the bold-tags (I put them there, hoping this forum won't mess up :p )
it also makes sure the tag is closed, or it will not touch it...
also, this may be of interest to you :
$str = eregi_replace("\[color=([#a-z0-9]*)\](.*)\[/color\]","< font color=\"\1\">\2< / font >",$str);
again, leave out the redundant spaces...
and, if you want to give them an [url]-tag, this does the trick for me :
$str = eregi_replace("\[url\]http://([\[])\[/url\]","< a href=\"http://\1\" target=\"_blank\">\1< / a >",$str);
$str = eregi_replace("\[url\]([^\[]*)\[/url\]", "< a href=\"http://\1\" target=\"_blank\">\1< / a >",$str);
$str = eregi_replace("\[url=http://(\[])\]([^\[]*)\[/url\]","< a href=\"http://\1\" target=\"_blank\" >\2< / a >",$str);
$str = eregi_replace("\*)\]([^\[]*)\[/url\]","< a href=\"http://\1\" target=\"_blank\" >\2< /a >",$str);
finally, for images and swf :
$str=eregi_replace("\[img\]([^\[]*)\[/img\]","< img src=\"\1\" border=0 >",$str);
$str=eregi_replace("\\[swf width=([^\\[]*) height=([^\\[]*)\\]([^\\[]*)\\[/swf\\]","< object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4\,0\,2\,0\" width=\"\\1\" height=\"\\2\">< param name=quality value=high><param name=\"SRC\" value=\"\\3\">< embed src=\"\\3\" quality=high pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" width=\"\\1\" height=\"\\2\"></ embed></object>", $str);
parts of this code is ripped from blazeboard, but I modified it a bit...
hope this helps...