我想刪除域擴展.com
使用preg_replace()
一個字符串,所以例如,如果對象的參數是facebook.com
,.com
將從串擦除。使用preg_replace從字符串中刪除域擴展?
我想這會工作,preg_replace(".com", "", $host);
不幸的是它返回的錯誤:Warning: preg_replace() [function.preg-replace]: No ending delimiter '.' found in
。
我然後試圖逃跑用反斜槓期間(認爲這是問題),它返回:
Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash
任何意見,答案或信息,將不勝感激! :)。
你並不需要一個正則表達式這一點,嘗試'str_replace函數(」。com」, 「」,$主機)' –