doing this might be very complex. one suggestion is to do this:
preg_match_all('#\[(javascript|other_bbctag)\](.|\s)*?\[/(javascript|other_bbctag)\]#i',$text,$matches);
for($i=0;$i<=count($matches[0]);$i++){
$rand[$i]=md5(rand(1,100000).rand(1,100000));
$text=str_replace($matches[0][$i],$rand[$i],$text); //encrypt text in bbc tags
}
//now replace
$text = str_replace(array('<', '>'), array('<', '>'), $text);
//now reconstitute
for($i=0;$i<=count($matches[0]);$i++){
$text=str_replace($rand[$i],$matches[0][$i],$text);
}
I'm fairly sure my regular expression pattern will work, but you'd have to enumerate the bbctags you wish to protect or I [could] use square brakets elsewhere [/could] I not?
Samuel