如何删除数字字符之间的空格字符


how to remove space character between number character?

我有这样的字符串:

$str = "old iccid : 809831 3245 345 new iccid : 999000 112221"

如何删除PHP中数字字符之间的空格字符,成为此输出?

$output = "old iccid : 8098313245345 new iccid : 999000112221";

将数字与字符分开并使用

$str="809831 3245 345";
$foo= str_replace(' ','',$str);
echo $foo; // gives 8098313245345

更新:这不是答案。请参阅评论。

$output = preg_replace( '/'d[ *]'d/', '', $str);

我从 xdazz (http://stackoverflow.com/users/762073/xdazz) 那里得到了答案,这种语法效果很好。

$output = preg_replace('/(?<='d)'s+(?='d)/', '', $str);