问题
Possible Duplicates:
Recursive BBCode Parsing
Strip BBCode via RegEx
What is the best way to remove all BBCode tags of a string and their content in PHP?
回答1:
<?php
function stripBBCode($text_to_search) {
$pattern = '|[[\/\!]*?[^\[\]]*?]|si';
$replace = '';
return preg_replace($pattern, $replace, $text_to_search);
}
echo stripBBCode($text_to_search);
?>
demo
来源:https://stackoverflow.com/questions/6777257/remove-bbcode-tags-and-their-content-in-php