Home > JavaScript, RegEx > Regular Expression to match UK residential telephone numbers

Regular Expression to match UK residential telephone numbers

A regular expression to match UK residential telephone numbers. It understands the difference between 02 and 01 numbers. It will accept all common formats and internationally formatted numbers.

Examples of accepted numbers:

  • 02081234567
  • 0208 123 4567
  • 020 8123 4567
  • 0208 123-4567
  • +44 208 123 4567
  • +44 (0) 208 123 4567
  • 01234 567 890
  • +44 0 1234 567-890
  • 07712 123 456

Examples of numbers that will not be accepted:

  • 020812345678
  • 123456789
  • 07612 123 4567
  • +33 345 876 1298

This is my first submission to the excellent regexlib.com regular expression library – I’d appreciate if you could vote for it!

/^((\(44\))( )?|(\(\+44\))( )?|(\+44)( )?|(44)( )?)?((0)|(\(0\)))?( )?(((1[0-9]{3})|(7[1-9]{1}[0-9]{2})|(20)( )?[7-8]{1})( )?([0-9]{3}[ -]?[0-9]{3})|(2[0-9]{2}( )?[0-9]{3}[ -]?[0-9]{4}))$/

Let me know if I’ve missed anything!

Update: This has been amended as per comments below, to allow 020 as a prefix for London, 07624 (Isle of Man) and 074xx xxxxxx.

Share this Article:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • email
  • FriendFeed
  • LinkedIn
  • Netvibes
  • Reddit
  • Slashdot
  • StumbleUpon
  • Tumblr
  • Twitter

booshtukka JavaScript, RegEx

  1. cmh55
    | #1

    ** 076 is not a valid prefix. **

    I am sure that people in the Channel islands (07624) will not be very impressed with that.

    Mobile telephones in mainland UK recently started using 075xx too.

    ** 0208 123 4567 **

    There is NO 0208 area code. London is 020. Just 020.

    ** +44 (0) 208 123 4567 **

    The form with (0) in it is NOT valid.

    http://revk.www.me.uk/2009/09/it-is-not-44-0207-123-4567.html

    http://www.itu.int/rec/T-REC-E.123/en

    Local numbers have between 4 and 8 digits. Area code (after zero) can be 2 to 5 digits long. NSN count is 9 or 10 depending on the area.

  2. booshtukka
    | #2

    Hi,

    This is intended to be used for form validation. As such, if we can expect that a user may enter:

    0208 123 4567
    +44 (0) 208 123 4567

    …we should allow those. They are valid, in my opinion, in that people may enter them, and it is trivial to convert these into a standard format for insertion into a database. This was originally written – as you correctly surmised – for mainland UK, and so the Channel islands were not supported. I should amend this though, you are correct, and I shall.

    Thanks for your comment!

  3. alan k
    | #3

    Mobile phones in the UK also now use 074xx xxxxxx.

    07624 is the Isle of Man, not the Channel Islands.

    • booshtukka
      | #4

      I have amended the regular expression. See the article.

  4. Ben
    | #5

    The London 020 area code is not the only (02x) area code.

    So far, 023, 024, 028 and 029 are also in use. Those are 02x codes. There are no 02xx area codes.

    The UK number format can be 2+8, 3+7, 4+6, 4+5, 5+5 or 5+4, where the leading 0 ‘trunk code’ is not included in the digit count.

    Ofcom maintain a detailed list of the allocations, published weekly as an Excel spreadsheet.

  1. No trackbacks yet.