tag:blogger.com,1999:blog-2156539095375223979.post5440084754443184725..comments2024-03-09T08:09:39.573-05:00Comments on Ken's Unified Communications Blog: Localized UK Dialing Rules for the OptimizerKen Laskohttp://www.blogger.com/profile/14298995806059683301noreply@blogger.comBlogger1125tag:blogger.com,1999:blog-2156539095375223979.post-22460166705599696002012-12-06T03:50:14.455-05:002012-12-06T03:50:14.455-05:00Yes, the UK is difficult to cater for. There's...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.<br /><br />I created a page with more detailed information on the local dialling rules here: <a href="http://www.aa-asterisk.org.uk/index.php/Local_dialling_rules_for_GB_telephone_numbers" rel="nofollow">Local dialling rules for GB telephone numbers</a> and the XML file is based on that.<br /><br /><br />The remainder of the patterns for the UK should look something like this:<br /><br /><b>Toll free:</b><br /> ^0(80(0\d{6,7}|8\d{7}|01111)|500\d{6})$<br />^\+44(80(0\d{6,7}|8\d{7}|01111)|500\d{6})$<br /><br /><b>Premium rate:</b><br /> ^0(9[018]\d{8}|87[123]\d{7}|70\d{8})$<br />^\+44(9[018]\d{8}|87[123]\d{7}|70\d{8})$<br /><b>or</b><br /> ^0((9[018]\d|87[123]|70\d)\d{7})$<br />^\+44((9[018]\d|87[123]|70\d)\d{7})$<br /><br /><b>National:</b><br /> ^0(1[1-9]\d{7,8}|2[03489]\d{8}|3[0347]\d{8}|5[56]\d{8}|8((4[2-5]|70)\d{7}|45464\d))(\D+\d+)?$<br />^\+44(1[1-9]\d{7,8}|2[03489]\d{8}|3[0347]\d{8}|5[56]\d{8}|8((4[2-5]|70)\d{7}|45464\d))$<br /><b>or</b><br /> ^0(1[1-9]\d{7,8}|(2[03489]|3[0347]|5[56])\d{8}|8((4[2-5]|70)\d{7}|45464\d))(\D+\d+)?$<br />^\+44(1[1-9]\d{7,8}|(2[03489]|3[0347]|5[56])\d{8}|8((4[2-5]|70)\d{7}|45464\d))$<br /><br /><b>Mobile:</b><br /> ^0(7([1-57-9]\d{8}|624\d{6}))$<br />^\+44(7([1-57-9]\d{8}|624\d{6}))$<br /><b>or</b><br /> ^0(7([1-57-9]\d{2}|624)\d{6})$<br />^\+44(7([1-57-9]\d{2}|624)\d{6})$<br /><br />with the outermost parentheses allowing the RegEx pattern to match and then capture the national significant number as $1.<br /><br />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.<br />g1smdhttp://www.aa-asterisk.org.uk/index.php/Category:UK_Number_Plannoreply@blogger.com