This will accept a UK phone number in national format (i.e. typically as entered by a user or from a Caller ID device - not international format (+44 etc.)). It supports the following standard formats that are commonly used by different phone providers:
(note the actual numbers are not validated except for the leading 0)
Number Format
Description
01234567890
no spaces / dashes
07123 4567890
space between STD code and number 5 digit STD codes
07123-4567890
dash between STD code and number 5 digit STD codes
0131 456 7890
space between STD code and number 4 digit STD codes 3+4 digit grouping for local number
0131-456 7890
dash between STD code and number 4 digit STD codes 3+4 digit grouping for local number
020 3459 7890
space between STD code and number 3 digit STD codes 4+4 digit grouping for local number
020-3459 7890
dash between STD code and number 3 digit STD codes 4+4 digit grouping for local number
(NOTE: Brackets for STD code (e.g. (01234) 567890) not supported even they are technically valid since no system uses that format these days and users do not typically write numbers in that format now)
Just wanted to add this here in case you want to match phone numbers that have 9 to 10 digits and that aren’t specific to UK. Slightly edited mask from Stack Overflow.