Back to Home

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!

Generate Regex Pattern

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

ComponentDescriptionMatches
^Start anchorEnsures match from string start
(\+44\s?7\d{3}|\(?07\d{3}\)?)Country/mobile prefixEither +44 format or 07 format
\s?Optional spaceOptional whitespace
\d{3}First groupExactly 3 digits
\s?Optional spaceOptional whitespace
\d{3}Second groupExactly 3 digits
$End anchorEnsures 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
  • +447123456789
  • 07123 456789
  • (07123) 456789
  • 07123456789
  • +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

  1. Mobile numbers only: This pattern specifically targets UK mobile numbers (07xxx)
  2. No landline support: Doesn't validate UK landline numbers
  3. No area code validation: Doesn't verify if mobile prefix is valid
  4. Limited formatting: Only supports spaces, not dashes or dots
  5. 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 +44 and 07 formats
  • Quick format checking for UK mobiles

For production, consider:

  • Adding landline number support
  • Using libphonenumber library 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!

Generate Regex Pattern