so
John Doe (dont remove space)
but
1 2 3 4 5 should be 12345
333 444 5555 should be 3334445555
thank you
I tried
Code: Select all
preg_replace('/(\d)+[\s](\d)+/',"$1$2", $v);
Moderator: General Moderators
Code: Select all
preg_replace('/(\d)+[\s](\d)+/',"$1$2", $v);
Code: Select all
echo preg_replace('/(?<=\d)\s+(?=\d)/',"", 'abc 1 2 3 4 def');No problem.yacahuma wrote:Thank you , exactly what I needed.
If you'd like to know some more (you seem to grasp the basics well enough), I highly recommend "Mastering Regular Expressions" by J. Friedl: THE book if it comes to regular expressions.yacahuma wrote:I always hate not spending time trying to learn regex.
Code: Select all
'/(?<=\d)\s+(?=\d)/' // replace with ''Code: Select all
'/(\d)\s+(\d)/' // replace with '$1$2'