You are given a phone number as a string number. The string number consists of digits, spaces ' ', and dashes '-'.
Reformat the phone number by applying the following steps:
Remove all spaces and dashes.
Group the digits from left to right into blocks of length
For the remaining digits:
• If
• If
• If
Join all blocks using the separator '-' and return the reformatted phone number.
Constraints:
number.length
number consists of digits and the characters '-' and ' '.
There are at least number.
You are given a phone number as a string number. The string number consists of digits, spaces ' ', and dashes '-'.
Reformat the phone number by applying the following steps:
Remove all spaces and dashes.
Group the digits from left to right into blocks of length
For the remaining digits:
• If
• If
• If
Join all blocks using the separator '-' and return the reformatted phone number.
Constraints:
number.length
number consists of digits and the characters '-' and ' '.
There are at least number.