I've been trying to figure this out all day..
I hope someone can help me out

I need a way to make it so certain tags (eg. [color=???][/color]) will only parse when they are outside of tags.

I've been playing around with it and everytime I get close, it messes up.
Here's what I have so far...

$regex = '/^(?!\[code\](.*?)\[color=(.*?)\](.*?)\[\/color\]^(?!(.*?)\[\/code\]))/';
$text = preg_replace($rregex,"<span style='color:$2'>$3</span>",$text);
Thanks in advance