【发布时间】:2011-08-20 09:24:31
【问题描述】:
我必须从 php 字符串中删除和替换 ASCII 换行符 (nl) 和运营商返回字符 (cr)。
我尝试使用以下语句将 $input 中的所有 ASCII (nl) 字符替换为空格,但没有成功:
preg_replace('/[\x0a]+/',' ',$input);
然后我尝试用空格替换所有ASCII控制字符,以下是语句:
ereg_replace('[[:cntrl:]]', ' ', $encoded); // didn't work
我也尝试了以下语句,但没有运气:
ereg_replace("[:cntrl:]", "", $pString);
preg_replace('/[\x00-\x1F\x7F]/', '', $input);
preg_replace('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/', '', $input);
从 php 字符串中删除 ASCII 换行符 (nl) 和运营商返回字符 (cr) 的正则表达式是什么?
我提到了以下几个链接:
ASCII Table
Regular Expressions
Regular expression posix
【问题讨论】:
-
“以下链接可能对您有所帮助”,为什么他们不能帮助您? SO 不是“给我代码”类型的网站!
标签: php preg-replace ascii