Reputation: 1290
I am trying to remove the following type of info from a string using php :
[url:2q57noz9]http://www.mysite.com/other/screencaps-from-ddd-t7099.html#p24174[/url:2q57noz9]
there are random numbers assigned to the [url: bit which makes it harder. I tried to adapt the following which works for image tags but I don't think it likes square brackets put in like I have. This is what I used for images :
$message = preg_replace(array("/<img[^>]+\>/i","/<!--[^>]+\-->/i"), "", $message);
and this is how I tried to modify it without success :
$message = preg_replace("/[[^>]+\]/i", "", $message);
Upvotes: 1
Views: 90
Reputation: 1652
add backslash before brackets
$message = preg_replace('/\[[^>]+\]/i', "", $message);
and use single Quotation for holding string
Upvotes: 1