【发布时间】:2011-09-30 01:45:28
【问题描述】:
我正在尝试从字符串中删除所有内容,但仅删除数字 (0-9)。
我认为这会起作用..
echo preg_replace("[^0-9]","",'604-619-5135');
但它会回显“604-619-5135”。我错过了什么???
【问题讨论】:
-
当更改输入字符串以适应它时,您的模式可以完美运行。
echo preg_replace("[^0-9]", "this", '0-9 is replaced');输出:this is replaced
标签: php regex string phone-number sanitization