Japanese Phone Number Regex for Python
/^(?:(?:\+81[\s.-]?|0)(?!0)(?=[0-9\s.-]{10,13}$)(?:[1-9][0-9]{0,3}[\s.-]?[0-9]{2,4}[\s.-]?[0-9]{4})|(?:\+81[\s.-]?|0)(?!0)(?:[1-9][0-9]{3}[\s.-]?[0-9]{1,2}[\s.-]?[0-9]{4}))$/What this pattern does
This page provides a comprehensive, battle-tested regular expression for matching japanese phone number, ported and verified for Python. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your Python project — whether you're validating in a Django view, a FastAPI endpoint, or a standalone data processing script.
Python Implementation
# Japanese Phone Number
# ReDoS-safe | RegexVault — Localization > Phone Numbers
import re
japanese_phone_number_pattern = re.compile(r'^(?:(?:\+81[\s.-]?|0)(?!0)(?=[0-9\s.-]{10,13}$)(?:[1-9][0-9]{0,3}[\s.-]?[0-9]{2,4}[\s.-]?[0-9]{4})|(?:\+81[\s.-]?|0)(?!0)(?:[1-9][0-9]{3}[\s.-]?[0-9]{1,2}[\s.-]?[0-9]{4}))$')
def validate_japanese_phone_number(value: str) -> bool:
return bool(japanese_phone_number_pattern.fullmatch(value))
# Example
print(validate_japanese_phone_number("+81 3 1234 5678")) # TrueTest Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
+81 3 1234 5678 | +81 0 1234 5678 |
03-1234-5678 | 031234567 |
+8190-1234-5678 | +82 3 1234 5678 |
090-1234-5678 | 03-12345-5678 |
+81 3-1234-5678 | — |
When to use this pattern
This pattern is drawn from the Localization > Phone Numbers category and carries a ReDoS-safe certification. That matters for Python developers because particularly important in Python web servers where CPU-bound regex operations can stall concurrent request handling. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.
Common Pitfalls
Japanese phone numbers display with hyphens in three groups. Mobile (090-XXXX-XXXX) and landline (03-XXXX-XXXX) have different group sizes. Preserve the grouping format in display.
Technical Notes
Japanese area codes: 03 (Tokyo), 06 (Osaka), 011 (Sapporo). Mobile numbers start with 070, 080, 090 (in domestic format). IP phone (050). +81 replaces the leading 0. Total 10-11 digits.
Have a pattern that belongs in the vault?
Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.
Submit a Pattern