Wednesday, December 5, 2012

Localized UK Dialing Rules for the Optimizer

Using data from a number of web sources and some helpful users, I've been able to create customized Lync dialing rules for over 30 countries worldwide and made them available to all via the Lync Dialing Rule Optimizer.  These customized dialing rules account for country-specific dialing patterns for local, national, international, toll-free, mobile, premium and service numbers.

However, true localized dialing rules have been out of reach for countries other than those in North America until now.  For all non-North American countries, I have been forced to create generic dialing patterns for local numbers simply because I don't have access to any source of local dialing rule data.  This isn't generally a problem because most local dialing rules are different enough from other patterns that conflicts are rare.  For example,  a local dialing rule for a country might specify that the number start with digits 2-9 and are between 5 and 6 digits in length.  As long as there aren't any other dialing patterns in that country that use that same pattern (ie national, international, mobile, service, toll-free or premium), there won't be a problem.  I try to make sure that is the case for all dialing rules created for the Optimizer, but it is sometimes difficult.

The United Kingdom has more than 60 different local dialing rules. Local numbers can be 4 to 8 digits in length and area codes have from 2 to 5 digits. Some 41 area codes have mixed length numbers where some numbers have a total 10 digits and others have only 9. In some area codes the local number cannot begin with certain digits, or certain digits will not come into use for many decades.  The generic UK local dialing rule used by the Optimizer tries to account for all these in a single regular expression, but obviously some generalizations had to be made.

Enter Ian Galpin of the UK.  Ian has made it a personal mission to ensure that the UK has a complete set of dialing rules written as regular expressions.   Over the past year, he's helped me ensure the regex for UK dialing rules are correct.  He's also created a localized set of dialing rules for every area code in the UK as an XML file along with a list of all the area codes used in the UK.  He's done this to help various telephony vendors create the appropriate rulesets for PBX deployments. I've been able to incorporate that into the Lync Dialing Rule Optimizer, so that UK users now have true customized local dialing rules for Lync that will differ depending on which area code you select in the Optimizer.

I've modified the Optimizer code to be able to use local dialing rules for other countries if available.  If anybody can point me to a similar source as provided by Ian for other countries, it would be greatly appreciated.

1 comment:

  1. Yes, the UK is difficult to cater for. There's a lot of variations and the official data has several errors ready to trip the unwary.

    I created a page with more detailed information on the local dialling rules here: Local dialling rules for GB telephone numbers and the XML file is based on that.

    The remainder of the patterns for the UK should look something like this:

    Toll free:

    Premium rate:



    with the outermost parentheses allowing the RegEx pattern to match and then capture the national significant number as $1.

    There's always multiple ways to optimise RegEx patterns and it soon becomes a battle between being readable (and therefore easy to maintain) and being efficient.