Issue
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.
Solution
Try:
$output = preg_replace('/(?<=\d)\s+(?=\d)/', '', $str);
Answered By - xdazz Answer Checked By - Mildred Charles (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.