开发者

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

开发者 https://www.devze.com 2023-03-07 21:11 出处:网络
This question already has answers here: Warning: preg_replace(): Unknown modifier (3 answers) Closed 3 years ago.
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

精彩评论

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