Download Cheat sheet PDF 12 pages · syntax, editors, patterns, Unicode, performance, debugging
Pattern

Regex for UK mobile number

UK mobile in 07XXX or +44 7XXX format.

The UK mobile number regex is ^(\+44\s?|0)7\d{3}\s?\d{6}$ — copy it below, or open it in the explainer for a token-by-token breakdown.

The pattern

^(\+44\s?|0)7\d{3}\s?\d{6}$
Try in explainer → Download cheat sheet ↓

What it matches

  • 07911 123456
  • +44 7911 123456
  • +447911123456

What it doesn't match

  • 08911 123456
  • +44 1234 567890
  • 07 9111 23456

Notes & gotchas

UK mobiles start with 07 (or +44 7). All UK mobile numbers are 11 digits including the leading 0, or 12 with +44 prefix.

Code in your language

Use the explainer's Code tab to generate ready-to-paste snippets in JavaScript, Python, Java, .NET, Go, Ruby, and PHP for this pattern.

Open in explainer →

Token-by-token breakdown

Every part of the pattern, left to right:

TokenMeaning
^start of string (or line in multiline mode)
(start of a capturing group
\+literal “+”
44literal text “44”
\s?optional (zero or one): whitespace
|OR — try the alternative
0literal text “0”
)end of group
7literal text “7”
\d{3}exactly 3 times: digit (0–9)
\s?optional (zero or one): whitespace
\d{6}exactly 6 times: digit (0–9)
$end of string (or line in multiline mode)

About this pattern

UK identifier formats are set by HMRC, Royal Mail, and the BACS payments scheme. The regex here matches the format; full validation may need an additional checksum or lookup.

Quick usage in different languages

This exact pattern — with the correct escaping and idioms for each language:

  • JavaScript: /^(\+44\s?|0)7\d{3}\s?\d{6}$/.test(value)
  • Python: re.match(r"^(\+44\s?|0)7\d{3}\s?\d{6}$", value)
  • Java: Pattern.compile("^(\\+44\\s?|0)7\\d{3}\\s?\\d{6}$").matcher(value).matches()
  • C# / .NET: Regex.IsMatch(value, @"^(\+44\s?|0)7\d{3}\s?\d{6}$")
  • Go: regexp.MustCompile(`^(\+44\s?|0)7\d{3}\s?\d{6}$`).MatchString(value)
  • Ruby: /^(\+44\s?|0)7\d{3}\s?\d{6}$/.match?(value)
  • PHP: preg_match('~^(\+44\s?|0)7\d{3}\s?\d{6}$~', $value)

The explainer’s Code tab regenerates these for any pattern you paste, and the downloadable cheat sheet bundles the breakdown, all seven snippets, and the pitfalls below onto one printable page.

Common pitfalls

  • Anchored to the whole string. This pattern uses ^ and $, so it requires the entire input to match. To find it inside a longer text, drop the anchors and use the global (g) flag.
  • Escape it correctly per language. In Java and JavaScript strings each backslash must be doubled (\\d); in Python, Go, and C# use raw/verbatim strings so the backslashes survive.
  • Validate beyond format. Matching the format doesn't guarantee the value is real. Confirm the uk mobile number against a source of truth (database, API, or checksum) where it matters.

Standards & sources

This pattern is based on the following authoritative specification(s) and issuing authorities. Formats can change — always confirm against the primary source.

Related patterns

More patterns in the United Kingdom 🇬🇧 category:

See also

Browse all 300 patterns in the library, or open this regex in the interactive explainer to see a token-by-token breakdown, test against custom input, and generate code in seven languages.


← Back to all patterns