preg_replace strip [quote] tags and everything between them

I need to use preg_replace to change this:

[nobbc]

[/nobbc]
When people introduce themselves on the board they don’t usually finish with a suicide note.

Into this:

When people introduce themselves on the board they don’t usually finish with a suicide note.

Basically I need a regular expression that will remove the [nobbc]

[/nobbc] and everything between the quote tags.

Hi there,

Try this:
[php]preg_replace(’/([/)*[^]]+]/’,’’,$string);[/php]

That worked. Thanks very much. :slight_smile:

Oops, not it does not. It takes out everything between [nobbc][/nobbc] as well, and more besides.

Okey doke, try this instead then:

[php]preg_replace(’/[quote(.*)[/quote]/is’,’’,$string);[/php]

Thanks again for the help, but this time I get:

Warning: preg_replace() [function.preg-replace]: Unknown modifier ‘q’ on line 57

Change it to this:

'/\[quote(.*)\[\/quote\]/is'

That seems to work nicely. Thanks.

Sponsor our Newsletter | Privacy Policy | Terms of Service