The example simply adds a whitespace character after two characters. This is a very simple example. For more advanced formatting you probably want to use libraries that properly parse the phone number to take local area codes or prefixes into account.