Php preg_replace help

Hello forums I’m trying to strip the [IMG] bbcode from vbulletin posted data

I tried this:


$data = 'test text [IMG]the url to the image[/IMG]';
$a = preg_replace('/[IMG].[/IMG]/i', ' ', $data);
echo $a;

uhmm didn’t work , what is wrong with my regular expression? I want it to strip everything from

Any ideas?

Thanks

You have some regex control characters in there which need escaping with \


$data = 'test text [IMG]the url to the image[/IMG]';
$a = preg_replace('/(\\[IMG\\].*\\[\\/IMG\\])/i', ' ', $data);
echo $a;

Hopefully they will make it through the SP editor …

Edit:

Also, you did not capture the intended match with (). Tested this in my pastebin, but had to double slash my slashes, the above should work though

Many thanks Cup it works, I thought all characters was supposed to be just a period . but it should be .*

thanks you look great!