REGEXVAULT
Identity & PII/Biometric & Physical
ReDoS Checked

Eye Color (Standardized) Regex for Python

/^(?:BLK|BLU|BRO|GRY|GRN|HAZ|MAR|MUL|PNK|DIC|UNK)$/i

All five implementations are free. Switch engines without signing in.

What this pattern does

This page provides a well-structured, multi-part regular expression for matching eye color (standardized), 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
# Eye Color (Standardized)
# ReDoS-checked | RegexVault — Identity & PII > Biometric & Physical

import re

eye_color_standardized_pattern = re.compile(r'^(?:BLK|BLU|BRO|GRY|GRN|HAZ|MAR|MUL|PNK|DIC|UNK)$')

def validate_eye_color_standardized(value: str) -> bool:
    return bool(eye_color_standardized_pattern.fullmatch(value))

# Example
print(validate_eye_color_standardized("BLK"))  # True

Test Cases

Matches (Valid)
Rejects (Invalid)
BLKBLUE
BLUbrown
BROblue-green
GRYB
GRNBLKU
HAZ
MAR
UNK

When to use this pattern

This pattern is drawn from the Identity & PII > Biometric & Physical category and has been checked for ReDoS risk. 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

Eye color descriptions vary significantly between jurisdictions. European documents may use different terminology. Standardized codes are only reliable within systems that share the same code table.

Technical Notes

AAMVA (American Association of Motor Vehicle Administrators) standard codes: BLK=black, BLU=blue, BRO=brown, GRY=gray, GRN=green, HAZ=hazel, MAR=maroon, MUL=multicolored, PNK=pink, DIC=dichromic, UNK=unknown. Used on US driver's licences.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Submissions join the review queue after automated validation.

Submit a Pattern