Re: Retrieving an area code from a telephone number



Andrew 2006 schrieb:
I'd like to implement a function that given a telephone number,
returns the area code.

E.g.
doExtract ("02084279274") = 020 # London
doExtract ("01697478288") = 016974 # Wigton, Cumbria
doExtract ("01189472872 ") = 0118 # Reading
doExtract ("01438311919") = 01438 # Stevenage

It appears that the only way to retrieve the correct area code would
be to check the numbers against a database of all current UK telephone
area codes.

That is the way to go. You should use a trie to store the area codes, it will probably provide the fastest possible decoding.

Christian
.


Quantcast