Skip to content

Instantly share code, notes, and snippets.

@natmchugh
Last active August 29, 2015 14:23
Show Gist options
  • Save natmchugh/9aaeeb879815d8716c9d to your computer and use it in GitHub Desktop.
Save natmchugh/9aaeeb879815d8716c9d to your computer and use it in GitHub Desktop.

Phone Number Formats

Below is a comma seperated list of phone numbers customers in the UK have typed into a web form. There was no required format or validation on characters used. Write a script to parse the list and output the numbers as a UK phone numbers in the 3 common display formats:

  • 0141 496 0018
  • (0141) 496 0018
  • +44 141 496 0018

The expected otput form for different dialing codes is given at https://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom#Format

0844 481 6666, (01482) 327111, 01614452884, 01142660939, (01204) 522345, 01246504536, 0115 948 2000, 08444 060910, 016977 2255, +44(0)1332 419700, 07503676534, 03332009090, 03700 100123, 03442 411 653, 0300200 3701, +44(0)141 309 3000, +44 (0) 3300 555 723, +4415395 33666, +44 20 7123 4567, 0292 018 0018, 0247 688 768, 0207 946 0018, 0239 283 4093, 02392 834092, 02380 833000, 0238 083 3001,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment