2011-05-22 92 views
2

道歉爲另一個preg_replace問題!PHP preg_replace錯誤:未知修飾符']'

,我發現了錯誤:

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

當運行下面的preg_replace:

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

我已經通過一對夫婦網上正則表達式的建設者運行正則表達式,似乎聲音。任何想法,我在這裏失蹤?我錯誤地使用]

回答

5

你需要在你的表達分隔符:

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

良好,即工作一種享受。非常感謝本傑明。 – lexnels 2011-05-23 08:52:43

相關問題