I need to make a regular expression that will help me format a number in this way.
Example:
We have this number222345678
I need an expression that can do this:22 234 5678
That is, after the first 2 numbers add a space, then add one after the next 3 and the last block is 4 numbers.
I currently have something like this:number.toString().replace(/\d{4,4}?(?=...)/g, "$& ")
Which only separates them every 4.
I have searched for an expression that does the same thing but I can't find anything, does anyone know how to do it? Beforehand thank you very much.
With capture groups:
Result:
22 234 5678