How to split mobile number into country code, area code and local number?

前端 未结 7 567
悲&欢浪女
悲&欢浪女 2020-12-03 10:33

How to split mobile number into country code, area code and local number? e.g +919567123456 after split

country code = 91

area code = 9567

local numb

7条回答
  •  [愿得一人]
    2020-12-03 11:12

    A very complex problem. First you need to determine the country code. Depending on the country code, the rest has to be splitted into area code and local number. But none of the three parts has a fixed length, not the hole number nor the area code and local part combination!

    Example: 4930123456789

    • 49 is the country code of Germany
    • 30 is the area code of Berlin
    • 123456789 is a local number in Berlin (no real one)

    Example: 493328123456

    • 49 is the country code of Germany
    • 3328 is the area code of Teltow
    • 123456 is a local number in Teltow (no real one)

    Example: 34971123456

    • 34 is the country code of Spain
    • 971 is the area code of Mallorca
    • 123456 is a local number on Mallorca (no real one)

提交回复
热议问题