preg_replace删除文本和标签

preg_replace('|[[\/\!]*?[^\[\]]*?]|si', '', $text);

This removes all the bb tags from the text. I am looking to remove the persons's signature as well. This has to be done before the tag replacement and I'd like to do it with one regex.

This should be removed completely:

[b][color=red]This is my signature[/color][/b]

Been playing around with it for a while and got nowhere.

Just write what you look for as a pattern:

$pattern = '(\[b]\[color=red](?:\w|\s)*\[/color]\[/b])';

Escape those characters which have a special meaning (e.g. the opening square bracket [).

That should do it.

for example something like this should work:

/((\s?\w)+|[[\/\!]*?[^\[\]]*?])/