Jump to content

Removing the text inside brackets


scvinodkumar

Recommended Posts

hi,

 

I have content like this

 

"success adding the records in the river table by scvinodkumar today at 6.36 pm

by scvinodkumar

 

[[Category:Test]]"

 

Now, i want to remove the "[[Category:Test]]" from the above content.

 

Please tell me how to remove this?

 

Link to comment
https://forums.phpfreaks.com/topic/166155-removing-the-text-inside-brackets/
Share on other sites

dpacmittal, the OP wants to remove, not match.

 

Try this:

 

Example:

$str = '"success adding the records in the river table by scvinodkumar today at 6.36 pm
by scvinodkumar

[[Category:Test]]"';

$str = preg_replace('#\[{2}[^]]+\]{2}#', '', $str);
echo $str;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.