Regular expression for GB based and only numeric phone number

There are some UK phone number regular expressions here.

The most highly rated one from that page is:

^(((\+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}))?$

It is described as:

Matches     +447222555555   | +44 7222 555 555 | (0722) 5555555 #2222
Non-Matches (+447222)555555 | +44(7222)555555  | (0722) 5555555 #22

Personally I would not put a strict regex on a phone number unless it is absolutely required to have the users actual phone number for identity verification or something involving payments. There are lots of variations of phone numbers, some users could even use Skype as their primary phone, and by putting a validation on you’re just going to block/frustrate users.

Also note you have got the UK format wrong, UK phone numbers should contain 11 digits and are normally in the format (01234) 123123 – we never use dashes and first number should always be a 0.

Leave a Comment