eregi_replace如何轉換這種此功能參數替換了preg_replace
eregi_replace('<[^>]*>', '', $stringToDisplay)
到的preg_replace?
eregi_replace如何轉換這種此功能參數替換了preg_replace
eregi_replace('<[^>]*>', '', $stringToDisplay)
到的preg_replace?
的PCRE regular expressions要求delimiters是分開optional modifiers模式(在這種情況下i
反映不區分大小寫的匹配):
preg_replace('/<[^>]*>/i', '', $stringToDisplay)
但因爲有沒有需要,而不情況下被解釋的信件,你可以省略i
修飾符。
如果您碰巧嘗試使用正則表達式解析HTML或類似的標記語言,請考慮使用正確的解析器。
嘗試
preg_replace('/\<[^>]*\>/i', '', $stringToDisplay)
``<` and `>不是元字符,不需要轉義。 – BoltClock 2010-12-05 20:01:34