gettoolz.app

Phone number (E.164) regex

An international number in E.164 form: a +, a country code that does not start with 0, and at most fifteen digits in all, with no spaces. Copy the pattern, with 4 inputs it accepts and 5 it rejects, each checked against it at build time.

Part of developer tools.

Pattern^\+[1-9]\d{1,14}$
JavaScript literal/^\+[1-9]\d{1,14}$/

What the phone number (e.164) regex accepts and rejects

Each result below is the output of the pattern itself, run on the input when this page was built — not a claim copied next to it. A wrong verdict stops the build.

Inputs tested against the Phone number (E.164) regex
InputResultWhy
+33612345678Passesa French mobile
+14155552671Passesa US number
+442071838750Passesa London landline
0612345678Failsnational format, no country code
+33 6 12 34 56 78Failsspaces
+1 (415) 555-2671Failspunctuation
+0123456Failsa country code cannot start with 0
+1234567890123456Failssixteen digits

What it wrongly lets through

These inputs match although they are not valid — checked the same way, so this list is as true as the one above.

Inputs the Phone number (E.164) regex wrongly accepts
InputResultWhy
+12Passesfar too short to be a real number

Limits

  • E.164 is the storage format, not what people type: normalise spaces, dots, dashes and a leading 00 to a + before matching, or the pattern will refuse most real input.
  • The length check is global. Whether a number is valid for its country — right length, allocated prefix — needs the numbering plan of that country, which is what a library such as libphonenumber carries.

Try it on your own input

Open this pattern in the regex tester with every example above on its own line. The link adds the g and m flags so that ^ and $ hold per line and every line is tested: the highlighted lines are the ones marked as passing here. Paste your own data in place of the examples — it is matched in your browser and never uploaded.

Other common regexes

Or open the regex tester empty and bring your own pattern.