
Are you a QOTWer? Do you want to start a thread that isn't a direct answer to the current QOTW? Then this place, gentle poster, is your friend.
( , Sun 1 Apr 2001, 1:00)
« Go Back | See The Full Thread

I havent tried yours out but how will it handle the 4 different main number formats I can think of:
020 XYYY YYYY - London (Where X = 7, 8 or 3)
01X1 YYY YYYY - Other Major City
01XXX YYY YYY - Towns
07XYY YYY YYY - Mobile (Where X = 7, 8 or 9)
01234-567890 to +44(01234)567890 would work fine but if you do a London one do you get:
020-71234567 to +44(02071)234567 (Incorrect) or do you get +44(020)71234567 (Correct)
Equally a Birmingham number of 0121-1234567, do you get:
+44(01211)234567 (Incorrect) or +44(0121)1234567 (Correct)
Also a Mobile should never have anything other than the first 0 in brackets as the rest is never optional:
+44(07712)345678 (Incorrect)
+44(0)7712345678 (Correct)
Actually now that I think about it it would probably be both more correct and easier to code to just to a straight swap of the initial 0 to +44(0) as If you're needing to add the country code chances are you aren't in the same area code so will need to dial the rest regardless. In other words forget all the times above where I say correct and just change them all to:
+44(0)2071234567
+44(0)1211234567
+44(0)1234567890
+44(0)7712345678
The above it closer to the recommended format and with some modifications you might want to have a look at
regexlib.com/REDetails.aspx?regexp_id=593 for this one:
^(((\+44\s?\d{4}|\(?0\d{4}\)?)\s?\d{3}\s?\d{3})|((\+44\s?\d{3}|\(?0\d{3}\)?)\s?\d{3}\s?\d{4})|((\+44\s?\d{2}|\(?0\d{2}\)?)\s?\d{4}\s?\d{4}))(\s?\#(\d{4}|\d{3}))?$
UK phone number regular expression. Allows +44 national code in addition to extension numbers of 3 or 4 digits.
Matches +447222555555 | +44 7222 555 555 | (0722) 5555555 #2222
Non-Matches (+447222)555555 | +44(7222)555555 | (0722) 5555555 #22
This doesnt help with the bracketing but might give you some ideas about how to handle the number validation.
*Gets headache*
*Goes to bed*
;-)
( , Sun 7 Jun 2009, 2:55, Reply)
« Go Back | See The Full Thread