Note that using Ask yourself why you feel the need to change the format that the user as used?
Whether they enter 353 or 00353861234567 or, sin of sins, 086-123-4567, why not accept that they have already used the format they are most comfortable with. For spacing, I feel very strongly that the spacing expected by the user is the spacing you should use.
There are lots of opinions out there about the best way to write a telephone number on a website.
Porn site Porn Hub now requires millions of users to log in via social media accounts linked to their passports and cell phones.
Porn Hub last year received 23 BILLION visits worldwide and almost 92 billion XXX videos were watched in total.
Most people remember phone numbers (especially their own) with a kind of rhythm based on (usually) the official spacing used in their region.
When they see their number in a spacing other than that which they expect, they might not immediately recognise it as their own phone number, and become confused.