REGEXVAULTv2.0
Identity & PII/Digital Identity
Verified Safe

Apple IDFA / Google GAID (Advertising 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 apple idfa / google gaid (advertising 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
// Apple IDFA / Google GAID (Advertising ID)
// ReDoS-safe | RegexVault — Identity & PII > Digital Identity

import java.util.regex.Pattern;

public class AppleIdfaGoogleGaidAdvertisingIdValidator {
    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("6D92078A-85A5-4F7E-A9D7-1A9A5A5A5A5A")); // true
    }
}

Test Cases

Matches (Valid)
Rejects (Invalid)
6D92078A-85A5-4F7E-A9D7-1A9A5A5A5A5A6D92078A-85A5-4F7E-A9D7-1A9A5A5A5
00000000-0000-4000-8000-0000000000006D92078A85A54F7EA9D71A9A5A5A5A5A
00000000-0000-0000-0000-000000000000

When to use this pattern

This pattern is drawn from the Identity & PII > Digital Identity 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

Since iOS 14.5 (2021), apps must request ATT (App Tracking Transparency) permission before accessing IDFA. A valid UUID format does not mean the user consented — check for the nil UUID (all zeros) as an opt-out signal.

Technical Notes

IDFA (iOS) and GAID (Android) are UUID v4 format advertising identifiers. The nil IDFA (00000000-0000-0000-0000-000000000000) indicates the user has opted out of tracking (iOS 14+ ATT framework). Google allows users to reset GAID at any time.

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