REGEXVAULTv2.0
Identity & PII/Health Identifiers
Verified Safe

US DEA Number (Drug Enforcement Administration) Regex for Python

/^[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 Python. 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 Python project — whether you're validating in a Django view, a FastAPI endpoint, or a standalone data processing script.

Python Implementation

Python
# US DEA Number (Drug Enforcement Administration)
# ReDoS-safe | RegexVault — Identity & PII > Health Identifiers

import re

us_dea_number_drug_enforcement_administration_pattern = re.compile(r'^[ABCDEFGHJKLMNPQRSTUX][A-Z9][0-9]{7}$')

def validate_us_dea_number_drug_enforcement_administration(value: str) -> bool:
    return bool(us_dea_number_drug_enforcement_administration_pattern.fullmatch(value))

# Example
print(validate_us_dea_number_drug_enforcement_administration("AB1234563"))  # True

Test Cases

Matches (Valid)
Rejects (Invalid)
AB1234563A12345678
AC1234568AB123456
BS1234568AB12345678
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 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

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