我想删除域扩展.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”, “”,$主机)' –