I receive a string conformed by numbers and points. I need those numbers to have a minimum length of 3, so, I have to add one or more zeros in from of the numbers with a lower length.
Example:
If I have:
233.14.205.1.194056.270132
I need it to be:
233.014.205.001.194056.270132
↑ ↑↑
(Note the 014
where there was a 14
and the 001
where there was a 1
)
I know I can explode the string, add the zeros I need and implode it again, but I want not to create a function for something that can solved with a native function (preg_replace
) and I am not very good with regex (yet).