UK Phone Number Validation Regex
• CronOS Team
regexphonevalidationtutorialuk-phone
Need to generate a regex pattern?
Use CronOS to generate any regex pattern you wish with natural language. Simply describe what you need, and we'll create the perfect regex pattern for you. It's completely free!
UK Phone Number Validation Regex
Validate UK phone numbers including mobile numbers starting with 07 and international format +44 using regex patterns.
Pattern Breakdown
regex
^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$
Components
| Component | Description | Matches |
|---|---|---|
^ | Start anchor | Ensures match from string start |
(\+44\s?7\d{3}|\(?07\d{3}\)?) | Country/mobile prefix | Either +44 format or 07 format |
\s? | Optional space | Optional whitespace |
\d{3} | First group | Exactly 3 digits |
\s? | Optional space | Optional whitespace |
\d{3} | Second group | Exactly 3 digits |
$ | End anchor | Ensures match to string end |
Detailed Breakdown
(\+44\s?7\d{3}\|\(?07\d{3}\)?)- Alternation group:\+44\s?7\d{3}- International format:+44(optional space) +7+ 3 digits\|- OR operator\(?07\d{3}\)?- UK format: optional(,07, 3 digits, optional)
\s?- Optional space separator\d{3}- Three digits\s?- Optional space separator\d{3}- Three digits
Examples
Valid:
+44 7123 456789+44712345678907123 456789(07123) 45678907123456789+44 7123 456 789
Invalid:
0712345678(missing digit - should be 11 digits total)06123456789(doesn't start with 07 or +44)+44 8123 456789(doesn't start with 7 after +44)07123-456789(dashes not supported, only spaces)+44 7123 45678(too short)
Implementation
JavaScript
javascript
const ukPhoneRegex = /^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$/;
ukPhoneRegex.test('+44 7123 456789'); // true
ukPhoneRegex.test('07123456789'); // true
ukPhoneRegex.test('(07123) 456789'); // true
ukPhoneRegex.test('06123456789'); // false (wrong prefix)
Python
python
import re
uk_phone_regex = r'^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$'
bool(re.match(uk_phone_regex, '+44 7123 456789')) # True
bool(re.match(uk_phone_regex, '07123456789')) # True
bool(re.match(uk_phone_regex, '06123456789')) # False
Go
go
ukPhoneRegex := regexp.MustCompile(`^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$`)
ukPhoneRegex.MatchString("+44 7123 456789") // true
ukPhoneRegex.MatchString("07123456789") // true
ukPhoneRegex.MatchString("06123456789") // false
Limitations
- Mobile numbers only: This pattern specifically targets UK mobile numbers (07xxx)
- No landline support: Doesn't validate UK landline numbers
- No area code validation: Doesn't verify if mobile prefix is valid
- Limited formatting: Only supports spaces, not dashes or dots
- Fixed length: Assumes 11-digit UK mobile format
When to Use
- UK mobile number validation
- Applications targeting UK users
- When you need to accept both
+44and07formats - Quick format checking for UK mobiles
For production, consider:
- Adding landline number support
- Using
libphonenumberlibrary for comprehensive validation - Validating mobile prefixes against known ranges
- Supporting additional formatting options
- Normalizing to E.164 format for storage
Need to generate a regex pattern?
Use CronOS to generate any regex pattern you wish with natural language. Simply describe what you need, and we'll create the perfect regex pattern for you. It's completely free!