$title = preg_replace('[RS]', '', $title);
// This removes [RS] [HF] [HF RS] [FS] [MU] RS HF FS from titles
$removes = array('[RS]', '[HF]', '[HF RS]', '[FS]', '[MU]', 'RS', 'HF', 'FS');
while ($removes as $revove)
{
$title = preg_replace($remove, '', $title);
}
preg_replace("/(\[[RS|HF|FS|MU]\])?/","",$string); //UNTESTED
preg_replace("/^(\[A-Z{2}\])/","",$string);
MR Happy, you need to examine the speed of your code, your running preg repalce lots of times when you only need to run it once
PHP:preg_replace("/\([[RS|HF|FS|MU]\])?/","",$string); //UNTESTED
$tags = array('RS','MS','FS','RS MU','MU');
$preg_compat = implode("|",$tags);
preg_replace("/\([[" . $preg_compat . "]\])?/","",$string); //UNTESTED
EDIT: Actually you have an error
return preg_replace($censors['match'], $censors['replace'], $text);
}
I've tried something like this but it gets messy. You have people who have stuff like [RS/HF/FS/MU] or RS-HF or [RS|HF][MULIT] or RS+1 or RS*3 and lots of other stuff which mess with your regex and have to take into consideration. Have a look through some posts on WBB and the prefixes they use. I tried but you just get people posting the craziest patterns you'd never think of which affect itnot really do, you can implode the array and the preg_escape them like so
PHP:$tags = array('RS','MS','FS','RS MU','MU'); $preg_compat = implode("|",$tags); preg_replace("/\([[" . $preg_compat . "]\])?/","",$string); //UNTESTED
what you want me to do, give you a cookie lol. i did say untested, example purposes and all that shizzle :P
// Replace naughty words in title
$topic_data['topic_title'] = censor_text($topic_data['topic_title']);
$topic_data['topic_title'] = preg_replace("/^(\[A-Z{2}\])/","",$topic_data['topic_title']);