随着preg_replace()
的使用,我想将字符串 http://www.vaidehielink.com/
更改为www.vaidehielink.com
。如何在php中preg_replace中设置多个参数
我已经成功地用下面的代码来获取www.vaidehielink.com/
结果:
$str = "http://www.vaidehielink.com/";
$pattern= '(http://)';
$copy_date = preg_replace($pattern, "", $str);
但我要寻找一个模式除了删除尾随/
是不可能的preg_replace() –
是的,但为什么??? – AbraCadaver
正则表达式对此没有必要。如果你真的想找到一个URL的主机部分,你可以使用PHP的内置'url_parse'函数而不是你自己的代码。 (当然,如果你只是在练习正则表达式,那么继续...) – RJHunter