REGEXVAULTv2.0
Identity & PII/Consent & Compliance
Verified Safe

GDPR Consent Record ID Regex for Java

/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i

What this pattern does

This page provides a well-structured, multi-part regular expression for matching gdpr consent record id, 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

Java
// GDPR Consent Record ID
// ReDoS-safe | RegexVault — Identity & PII > Consent & Compliance

import java.util.regex.Pattern;

public class GdprConsentRecordIdValidator {
    private static final Pattern PATTERN =
        Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$");

    public static boolean validate(String input) {
        return PATTERN.matcher(input).matches();
    }

    // Example
    public static void main(String[] args) {
        System.out.println(validate("550e8400-e29b-41d4-a716-446655440000")); // true
    }
}

Test Cases

Matches (Valid)
Rejects (Invalid)
550e8400-e29b-41d4-a716-446655440000550e8400-e29b-41d4-a716-44665544000
6ba7b810-9dad-41d1-80b4-00c04fd430c8550e8400e29b41d4a716446655440000
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 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

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