2

Apologies for yet another preg_replace question!

I'm getting the error:

Warning: preg_replace() [function.preg-replace]: Unknown modifier ']' in C:\xampp\htdocs\reg.php on line 6

When running the following preg_replace:

$newContent = preg_replace('<img [^>]*.gif[^>]*?>','MATCHED',$newContent);

I've run the regex through a couple of online regex builders and it seems sound. Any ideas what I'm missing here? Am I using ] incorrectly?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
lexnels
  • 23
  • 3

1 Answers1

5

You need a delimiter around your expression:

$newContent = preg_replace('|<img [^>]*.gif[^>]*?>|','MATCHED',$newContent);
BenMorel
  • 34,448
  • 50
  • 182
  • 322