REGEXVAULTv2.0
Identity & PII/Digital Identity
Verified Safe

IMEI Number (Mobile Device) Regex for Java

/^[0-9]{15}$/

What this pattern does

This page provides a lightweight, single-purpose regular expression for matching imei number (mobile device), ported and verified for Java. Identity and credential patterns need both correctness and safety, since they're frequent targets for adversarial input. 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

Java
// IMEI Number (Mobile Device)
// ReDoS-safe | RegexVault — Identity & PII > Digital Identity

import java.util.regex.Pattern;

public class ImeiNumberMobileDeviceValidator {
    private static final Pattern PATTERN =
        Pattern.compile("^[0-9]{15}$");

    public static boolean validate(String input) {
        return PATTERN.matcher(input).matches();
    }

    // Example
    public static void main(String[] args) {
        System.out.println(validate("356938035643809")); // true
    }
}

Test Cases

Matches (Valid)
Rejects (Invalid)
35693803564380935693803564380
4901542032375183569380356438090
35867400956789735693803564380A
356938-035643809

When to use this pattern

This pattern is drawn from the Identity & PII > Digital Identity 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

IMEI tracking can circumvent SIM-swapping — if you have the IMEI, you can track the device regardless of which SIM is in it. Governments can block stolen devices by IMEI (CEIR database). Treat with care.

Technical Notes

IMEI structure: 8-digit TAC (Type Allocation Code, identifies manufacturer/model) + 6-digit serial number + 1 Luhn check digit. IMEI2 is used for dual-SIM devices. IMEISV is 16 digits (includes software version). Always validate Luhn checksum.

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