Hey all,
I'm working on a very, VERY simple UBB-style code parser for my site. I don't need anything elaborate like a forum would have, just a few ways to spice up some articles and comments.
So this is what I've got:
// Bold
$szText = preg_replace("/\[b\](.*?)\[\/b\]/sim", "<span class=\"bold\">$1</span>", $szText);
// Italics
$szText = preg_replace("/\[i\](.*?)\[\/i\]/sim", "<span class=\"italic\">$1</span>", $szText);
// Underline
$szText = preg_replace("/\[u\](.*?)\[\/u\]/sim", "<span class=\"underline\">$1</span>", $szText);
// Code
$szText = preg_replace(NO IDEA WHAT TO PUT HERE, OR HERE, $szText);
$szText = preg_replace("/\[code\](.*?)\[\/code\]/sim", "<pre>$1</pre>", $szText);
I'm struggling on one thing though, and that's with the
tags. See the first rule? NO IDEA WHAT TO PUT HERE, what I'm trying to do is remove all <br />s, before I parse it. I need to do this to retain proper styling, as it's already been nl2br'd.
So this:
Batman<br />\nSuperman
would become:
Batman\nSuperman
Anyone have any idea on how I can remove the <br />s from within a
WITHOUT str_replacing them all away (as obviously, there might be more than just a code section, and I want to retain those <br />s.