US DEA Number (Drug Enforcement Administration) Regex for Java
/^[ABCDEFGHJKLMNPQRSTUX][A-Z9][0-9]{7}$/What this pattern does
This page provides a well-structured, multi-part regular expression for matching us dea number (drug enforcement administration), 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
// US DEA Number (Drug Enforcement Administration)
// ReDoS-safe | RegexVault — Identity & PII > Health Identifiers
import java.util.regex.Pattern;
public class UsDeaNumberDrugEnforcementAdministrationValidator {
private static final Pattern PATTERN =
Pattern.compile("^[ABCDEFGHJKLMNPQRSTUX][A-Z9][0-9]{7}$");
public static boolean validate(String input) {
return PATTERN.matcher(input).matches();
}
// Example
public static void main(String[] args) {
System.out.println(validate("AB1234563")); // true
}
}Test Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
AB1234563 | A12345678 |
AC1234568 | AB123456 |
BS1234568 | AB12345678 |
| — | ZB1234563 |
When to use this pattern
This pattern is drawn from the Identity & PII > Health Identifiers 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
Verify the checksum — structurally valid DEA numbers with wrong checksums are commonly found in prescription fraud. First letter: A=hospital/clinic, B=pharmacy, C=practitioner, D=teaching hospital, E=manufacturer, F=distributor, G=researcher.
Technical Notes
DEA number structure: registrant type letter (A=hospital, B=pharmacy, C=practitioner, etc.) + registrant first letter of last name or 9 + 7 digits. Check digit: (d1+d3+d5) + 2*(d2+d4+d6), last digit of sum's rightmost digit = d7.
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