Japanese Phone Number Regex for Java
/^(?:(?:\+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 Java. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your Java project — whether you're validating in a Spring Boot controller, a Jakarta EE service, or a standalone utility class.
Java Implementation
// Japanese Phone Number
// ReDoS-safe | RegexVault — Localization > Phone Numbers
import java.util.regex.Pattern;
public class JapanesePhoneNumberValidator {
private static final Pattern PATTERN =
Pattern.compile("^(?:(?:\\+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}))$");
public static boolean validate(String input) {
return PATTERN.matcher(input).matches();
}
// Example
public static void main(String[] args) {
System.out.println(validate("+81 3 1234 5678")); // true
}
}Test 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 Java developers because critical in Java applications since the JVM regex engine uses backtracking and is susceptible to ReDoS without careful pattern design. 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