how to define regex (preg_replace) to removes space between number character

I have string like this:

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

How to define regex in order to remove the space character between number character in PHP, to become this output?

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

i've tried to use this syntax:

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

but didn't work well.

Answers


Try:

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

Need Your Help

Rails transforming Query from Rails 3.2.12 to 4.0.0 Errors

ruby-on-rails ruby ruby-on-rails-4

Hi I've got some problems convertigs Querys from My 3.2.12 Rails app to the new converted 4.2.0 version.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.