我使用这些代码行来删除所有的标点符号,符号等,你可以在数组中看到它们,
$pattern_page = array("+",",".","-","'","\"","&","!","?",":",";","#","~","=","/","$","£","^","(",")","_","<",">"); $pg_url = str_replace($pattern_page,' ',strtolower($pg_url));
但是我想让它更简单,因为它看起来很傻,列出我想要删除的数组中的所有东西,因为可能还有一些其他要删除的特殊字符.
我想到使用下面的正则表达式,
$pg_url = preg_replace("/\W+/"," ",$pg_url);
但它不会消除不足的成绩 – _
什么是最好的方式来删除所有这些东西?可以正常表达吗?
根据你想要的贪心,你可以做一些事情:
原文链接:https://www.f2er.com/php/140185.html$pg_url = preg_replace("/[^a-zA-Z 0-9]+/",$pg_url);
这将取代任何不是字母,数字或空格的内容.