GDPR Consent Record ID Regex for Python
/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iWhat this pattern does
This page provides a well-structured, multi-part regular expression for matching gdpr consent record id, 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
# GDPR Consent Record ID
# ReDoS-safe | RegexVault — Identity & PII > Consent & Compliance
import re
gdpr_consent_record_id_pattern = re.compile(r'^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$')
def validate_gdpr_consent_record_id(value: str) -> bool:
return bool(gdpr_consent_record_id_pattern.fullmatch(value))
# Example
print(validate_gdpr_consent_record_id("550e8400-e29b-41d4-a716-446655440000")) # TrueTest Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
550e8400-e29b-41d4-a716-446655440000 | 550e8400-e29b-41d4-a716-44665544000 |
6ba7b810-9dad-41d1-80b4-00c04fd430c8 | 550e8400e29b41d4a716446655440000 |
| — | xxxxxxxx-xxxx-4xxx-xxxx-xxxxxxxxxxxx |
When to use this pattern
This pattern is drawn from the Identity & PII > Consent & Compliance 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
Consent records must be retained as long as the data is processed (and for the limitation period of any regulatory claim). Deleting consent records along with user data is a common compliance mistake.
Technical Notes
Consent records under GDPR Article 7 must be documented with: who consented, when, what they consented to, and how. UUID v4 is the standard format for consent record IDs. Link the consent ID to: user ID, timestamp, purpose, version of privacy notice, withdrawal date (if applicable).
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