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.