REGEXVAULTv2.0
Identity & PII/Health Identifiers
Verified Safe

US DEA Number (Drug Enforcement Administration) Regex for Go

/^[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 Go. 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 Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.

Go Implementation

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

package validation

import "regexp"

var usDeaNumberDrugEnforcementAdministrationRe = regexp.MustCompile(`^[ABCDEFGHJKLMNPQRSTUX][A-Z9][0-9]{7}$`)

func ValidateUsDeaNumberDrugEnforcementAdministration(s string) bool {
    return usDeaNumberDrugEnforcementAdministrationRe.MatchString(s)
}

// Example
// fmt.Println(ValidateUsDeaNumberDrugEnforcementAdministration("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 Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. 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