php怎样去除字符串中的数字

来自:互联网
时间:2020-10-08
阅读:

php去除字符串中数字的方法:

方法简单,代码为:

$class=preg_replace("\\d+",'', $res);

需要使用preg_replace函数,但是只是这么写的话,会报错

Warning: preg_replace(): Delimiter must not be alphanumeric or backslash

翻译过来就是定界符不能是字母数字或反斜线。

想了一下,在正则表达式首尾加了一对/

$class=preg_replace("/\\d+/",'', $res);
返回顶部
顶部