UK Phone Number Regex

^(?:(?:\+44)|(?:0))(?:\d{10}|\d{9})$

Validate UK phone numbers starting with +44 or 0. Supports both 10 and 11 digit formats.

Test This Pattern →

Pattern Breakdown

Understanding the regex pattern ^(?:(?:\+44)|(?:0))(?:\d{10}|\d{9})$:

  • ^ - Start of string
  • $ - End of string
  • \d - Any digit (0-9)
  • ? - Optional (zero or one)
  • + - One or more
  • (...) - Capturing group
  • (?:...) - Non-capturing group
  • {n,m} - Quantifier (n to m times)
  • | - Alternation (OR)

Examples

Input Result Explanation
+447911123456 ✓ Match Mobile with +44
02071234567 ✓ Match London landline
07911123456 ✓ Match Mobile with 0

Code Examples

JavaScript

JavaScript
const pattern = /^(?:(?:\+44)|(?:0))(?:\d{10}|\d{9})$/;
const text = "+447911123456";

// Test if string matches
if (pattern.test(text)) {
  console.log("Valid!");
}

// Extract matches
const matches = text.match(pattern);
console.log(matches);

Python

Python
import re

pattern = r'^(?:(?:\+44)|(?:0))(?:\d{10}|\d{9})$'
text = "+447911123456"

# Test if string matches
if re.match(pattern, text):
    print("Valid!")

# Find all matches
matches = re.findall(pattern, text)
print(matches)

PHP

PHP
<?php
$pattern = '/^(?:(?:\+44)|(?:0))(?:\d{10}|\d{9})$/';
$text = "+447911123456";

// Test if string matches
if (preg_match($pattern, $text)) {
    echo "Valid!";
}

// Find all matches
preg_match_all($pattern, $text, $matches);
print_r($matches);
?>

Java

Java
import java.util.regex.*;

String pattern = "^(?:(?:\\+44)|(?:0))(?:\\d{10}|\\d{9})$";
String text = "+447911123456";

Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(text);

if (m.matches()) {
    System.out.println("Valid!");
}

Use Cases

Common applications: UK-specific applications, local validation

Frequently Asked Questions

What is the regex pattern for uk phone number regex?
The regex pattern is: ^(?:(?:\+44)|(?:0))(?:\d{10}|\d{9})$. Validate UK phone numbers starting with +44 or 0. Supports both 10 and 11 digit formats.
How do I use the uk phone number regex pattern in JavaScript?
In JavaScript: const regex = new RegExp('^(?:(?:\\+44)|(?:0))(?:\\d{10}|\\d{9})$'); or const regex = /^(?:(?:\+44)|(?:0))(?:\d{10}|\d{9})$/;
Does this pattern work in Python?
Yes, use: import re; pattern = re.compile(r'^(?:(?:\+44)|(?:0))(?:\d{10}|\d{9})$') in Python. Most regex patterns are cross-language compatible.
What are common use cases for uk phone number regex?
UK-specific applications, local validation

Related Regex Patterns

More Regex Tools

GetDevUtils offers a suite of developer tools including: