REGEXVAULTv2.0
Identity & PII/Digital Identity
Verified Safe

Apple IDFA / Google GAID (Advertising 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}$/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 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
# Apple IDFA / Google GAID (Advertising ID)
# ReDoS-safe | RegexVault — Identity & PII > Digital Identity

import re

apple_idfa_google_gaid_advertising_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_apple_idfa_google_gaid_advertising_id(value: str) -> bool:
    return bool(apple_idfa_google_gaid_advertising_id_pattern.fullmatch(value))

# Example
print(validate_apple_idfa_google_gaid_advertising_id("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 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

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