当前位置:Gxlcms > PHP教程 > preg_replace匹配的正则表达式

preg_replace匹配的正则表达式

时间:2021-07-01 10:21:17 帮助过:24人阅读

求一个preg_replace匹配的正则表达式
用PHP ,preg_replace函数匹配一个正则

字符串为"house and market and "
替换掉最后一个and,要输出结果为"house and market "

试了半天没写出来,谢谢各位大侠给个匹配的正则


------解决方案--------------------
$str = "house and market and ";
$str = preg_replace('/and(\s*)$/', '', $str);
var_dump($str);
?>
如何。

人气教程排行