Mobile Number Regex
Validates a 10-digit mobile number with an optional international dialing prefix such as +91 or +1, allowing a single space or hyphen between the country code and the number.
Regex Pattern
^(?:\+\d{1,3}[-\s]?)?\d{10}$Pattern Breakdown
Hover over a token to see what it does.
| Token | Meaning |
|---|---|
| ^ | Anchors the match to the start of the string |
| (?:\+\d{1,3}[-\s]?)? | Non-capturing group marking the entire country-code prefix as optional |
| \+ | Literal plus sign that begins an international dialing code |
| \d{1,3} | One to three digits representing the country calling code |
| [-\s]? | An optional single hyphen or whitespace character separating the code from the number |
| \d{10} | Exactly ten digits making up the local mobile number |
| $ | Anchors the match to the end of the string |
Detailed Explanation
What it does
This pattern checks that a string is a 10-digit mobile number, optionally preceded by a + and a 1-3 digit country calling code with at most one separating space or hyphen. It rejects numbers with the wrong digit count, letters, or multiple separators.
Why it works
The optional non-capturing group at the start greedily attempts to consume a leading plus, calling code, and separator, but because it is wrapped in `?` the engine can also skip it entirely for domestic numbers. Requiring exactly `\d{10}` afterward pins down the local number length, and anchoring with `^`/`$` prevents partial matches such as an 11-digit string with an extra trailing digit.
Common use cases
- Validating a phone field on a signup or checkout form before submission
- Normalizing user-entered contact numbers in a CRM import pipeline
- Filtering SMS recipient lists to remove obviously malformed numbers
- Client-side validation paired with a stricter server-side libphonenumber check
Edge cases
- Numbers with country codes that are not exactly 1-3 digits (rare edge codes) will not validate correctly
- A domestic number with a leading 0 trunk prefix, like 07123456789, is rejected because it has 11 digits with no matching country code
- Ambiguous strings where the digit count could be split between code and number in multiple ways may fail even though a human would read them as valid
- Numbers written with parentheses around the area code, like +1 (415) 555-2671, are not supported
Limitations
- Does not validate that the country code or number actually corresponds to a real, assigned number
- Assumes a fixed 10-digit local number length, which does not hold for every country
- Does not support multiple internal separators or extensions
- For production-grade validation, a dedicated library like libphonenumber is far more reliable than a single regex
Interactive Tester
Edit the pattern or text below — matching runs live in your browser.
Test Cases
Editable — add your own inputs to see if they pass.
| Input | Expected | Result | |
|---|---|---|---|
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass | |||
| Pass |
Language Variants
Production-ready examples in 12 languages.
const mobileRegex = /^(?:\+\d{1,3}[-\s]?)?\d{10}$/;
console.log(mobileRegex.test('+919876543210')); // trueCommon Mistakes
Hardcoding a fixed total length that assumes every country code is exactly 2 digits
Fix: Use a flexible `\d{1,3}` quantifier for the country code so 1, 2, and 3 digit codes all validate correctly
Forgetting to allow an optional separator, causing valid inputs like '+91 9876543210' to fail
Fix: Include an optional `[-\s]?` between the country code and the local number
Assuming every country uses a 10-digit local number
Fix: Adjust the local-number quantifier per region, or use a dedicated phone-parsing library for multi-country support
Performance Notes
- The optional prefix group is small and bounded (at most 3 digits plus one separator), so it cannot cause catastrophic backtracking
- Fixed-length `\d{10}` quantifiers are fast to evaluate since the engine does not need to explore variable-length alternatives
- Precompile the regex once outside of loops when validating large batches of phone numbers
Browser Compatibility
| Engine | Supported | Notes |
|---|---|---|
| Chrome | Yes | — |
| Firefox | Yes | — |
| Safari | Yes | — |
| Edge | Yes | — |
| Node.js | Yes | — |
Work with this pattern
Take this expression further — test it against your own data, adapt it in the builder, or read up on the syntax behind it.
Regex Tester
Test a regular expression against sample text and see every match highlighted live.
Regex Generator
Build a pattern by clicking blocks — no syntax memorisation required.
Regular Expressions Guide
What regex is, how the syntax works, and the mistakes that trip people up.
Regex Cheat Sheet
Every token, quantifier, and assertion on one printable page.
Python Regex Guide
The re module end to end — search, match, findall, groups, and substitution.
Regex Pattern Library
100+ ready-to-use patterns for email, URLs, dates, IPs, and more.