-1
我知道有很多問題,但我沒有發現任何與我的問題相匹配的問題。我想這個表達式轉換的preg_replace:如何將棘手的ereg_replace轉換爲preg_replace?
$a = ereg_replace('[-a-z0-9!#$%&\'*+/=?^_`{|}~][email protected]([.]?[a-zA-Z0-9_/-])*','', $a);
到目前爲止已經試過的,但沒有工作:
$a = ereg_replace('/[-a-z0-9!#$%&\'*+/=?^_`{|}~][email protected]([.]?[a-zA-Z0-9_/-])*/','', $a);
$a = ereg_replace('|[-a-z0-9!#$%&\'*+/=?^_`{|}~][email protected]([.]?[a-zA-Z0-9_/-])*|','', $a);
這裏是第二行的錯誤消息:
Warning: preg_replace(): Unknown modifier '}' in
嘗試'preg_quote'在角色類中的東西。 – 2013-02-21 22:50:19
在第二個中,您正在使用模式內的分隔符而不引用它(僅在'}') – 2013-02-21 22:51:21
轉義分隔符之前。或者使用不存在於你的人物列表中的分隔符,例如''°。如果一切都失敗'preg_match(「\ 001 [....] \ 001」'總是替代選擇。 – mario 2013-02-21 22:52:13