--- sites/all/modules/phone/phone.gb.inc-old Mon Jan 3 13:40:32 2011 +++ sites/all/modules/phone/phone.gb.inc Wed May 4 16:38:45 2011 @@ -15,7 +15,7 @@ } /** - * Verifies that $phonenumber is a valid eleven-digit United Kingdom phone number + * Verifies that $phonenumber is a valid ten or eleven digit United Kingdom phone number * * Regular expression adapted from Amos Hurd's regex at RegExLib.com * @@ -40,13 +40,13 @@ */ $regex = "/ ( - (^\+44\s?(\(0\))?\d{4}|^\(?0\d{4}\)?){1}\s?\d{3}\s?\d{3} # 4 digit area code with optional +44 internationalisation or not, optional spaces and brackets. + (^\+44\s?(\(0\))?\d{4}|^\(?0\d{4}\)?){1}\s?\d{3}\s?\d{2,3} # 4 digit area code with optional +44 internationalisation or not, optional spaces and brackets. | - (^\+44\s?(\(0\))?\d{3}|^\(?0\d{3}\)?){1}\s?\d{3}\s?\d{4} # 3 digit area code with optional +44 internationalisation or not, optional spaces and brackets. + (^\+44\s?(\(0\))?\d{3}|^\(?0\d{3}\)?){1}\s?\d{3}\s?\d{3,4} # 3 digit area code with optional +44 internationalisation or not, optional spaces and brackets. | - (^\+44\s?(\(0\))?\d{2}|^\(?0\d{2}\)?){1}\s?\d{4}\s?\d{4} # 2 digit area code with optional +44 internationalisation or not, optional spaces and brackets. + (^\+44\s?(\(0\))?\d{2}|^\(?0\d{2}\)?){1}\s?\d{4}\s?\d{3,4} # 2 digit area code with optional +44 internationalisation or not, optional spaces and brackets. | - (^\+44\s?(\(0\))?\d{1}|^\(?0\d{1}\)?){1}\s?\d{5}\s?\d{5} # 1 digit area code with optional +44 internationalisation or not, optional spaces and brackets. + (^\+44\s?(\(0\))?\d{1}|^\(?0\d{1}\)?){1}\s?\d{5}\s?\d{4,5} # 1 digit area code with optional +44 internationalisation or not, optional spaces and brackets. ) (\s?\#\d*)? # optional extension number shown with a hash divider /x"; @@ -74,18 +74,18 @@ if (preg_match( "/ ( - \+44\s\(0\)\d{4}\s\d{3}\s\d{3} # 4 digit area code + \+44\s\(0\)\d{4}\s\d{3}\s\d{2,3} # 4 digit area code | - \+44\s\(0\)\d{3}\s\d{3}\s\d{4} # 3 digit area code + \+44\s\(0\)\d{3}\s\d{3}\s\d{3,4} # 3 digit area code | - \+44\s\(0\)\d{2}\s\d{4}\s\d{4} # 2 digit area code + \+44\s\(0\)\d{2}\s\d{4}\s\d{3,4} # 2 digit area code ) (\s\#\d*)? /",$phonenumber)) { return $phonenumber; } else { - //Simplify to 10 digit number and clean up ready for international reformat. + //Simplify to 9 or 10 digit number and clean up ready for international reformat. $phonenumber = preg_replace("/^(\+44)?\s?(\(?0\)?)?/","",$phonenumber); $phonenumber = preg_replace("/\(/","",$phonenumber); $phonenumber = preg_replace("/\(0/","",$phonenumber); @@ -100,21 +100,21 @@ \s+ # ignore required separator to make a distinction with other area codes (\d{3}) # capture first set of numbers in the local number \s* # ignore optional separator - (\d{3}) # capture second set of numbers in the local number + (\d{2,3}) # capture second set of numbers in the local number | # 3 digit area code. (\d{3}) # capture 3 digit area code \s+ # ignore required seperator (\d{3}) # capture first set of numbers in the local number \s* # ignore possible boundary - (\d{4}) # capture second set of numbers in the local number + (\d{3,4}) # capture second set of numbers in the local number | # 2 digit area code. (\d{2}) # capture 2 digit area code \s+ # ignore required boundary to make a distinction with other area codes (\d{4}) # capture first set of numbers in the local number \s* # ignore possible boundary - (\d{4}) # capture second set of numbers in the local number + (\d{3,4}) # capture second set of numbers in the local number ) # capture the optional extension number (\s*\#)?