开发者

PHP preg_replace error: Unknown modifier ']' [duplicate]

This question already has answers here: Warning: preg_replace(): Unknown modifier (3 answers) Closed 3 years ago.

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开发者_C百科 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?


You need a delimiter around your expression:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜