PHP PHP正则表达式 - 从字符串中删除特殊字符

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP PHP正则表达式 - 从字符串中删除特殊字符相关的知识,希望对你有一定的参考价值。

//Remove from a single line string
$output = "Likening ‘not-critical’ with";
$output = preg_replace('/[^(\x20-\x7F)]*/','', $output);
echo $output;

//Remove from a multi-line string
$output = "Likening ‘not-critical’ with \n Likening ‘not-critical’ with \r Likening ‘not-critical’ with. ' ! -.";
$output = preg_replace('/[^(\x20-\x7F)\x0A\x0D]*/','', $output);
echo $output;

以上是关于PHP PHP正则表达式 - 从字符串中删除特殊字符的主要内容,如果未能解决你的问题,请参考以下文章