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

Privacy Policy Version Identifier Regex for PHP

/^v([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:-([a-zA-Z0-9]+))?$/i

What this pattern does

This page provides a comprehensive, battle-tested regular expression for matching privacy policy version identifier, ported and verified for PHP. 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 PHP project — whether you're validating in a Laravel validator, a WordPress plugin, or a standalone PHP script.

Php Implementation

Php
<?php
// Privacy Policy Version Identifier
// ReDoS-safe | RegexVault — Identity & PII > Consent & Compliance

define('PRIVACY_POLICY_VERSION_IDENTIFIER_PATTERN', '/^v([0-9]+)\.([0-9]+)(?:\.([0-9]+))?(?:-([a-zA-Z0-9]+))?$/');

function validate_privacy_policy_version_identifier(string $input): bool {
    return (bool) preg_match(PRIVACY_POLICY_VERSION_IDENTIFIER_PATTERN, $input);
}

// Example
var_dump(validate_privacy_policy_version_identifier("v1.0")); // bool(true)

Test Cases

Matches (Valid)
Rejects (Invalid)
v1.01.0
v2.1.0v1
v3.0.1-gdprv1.0.0.0
v1.2.3v.1.0
v10.0version-1.0

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 PHP developers because especially relevant in PHP where PCRE backtracking limits can trigger silent failures on malicious input. 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

Material changes to a privacy policy (new data uses, new third-party sharing) require fresh consent under GDPR. Version tracking allows identification of which users need re-consent after a policy update.

Technical Notes

Capture groups: 1=major, 2=minor, 3=patch, 4=label (e.g., 'gdpr', 'ccpa'). Store the version of the privacy policy that was in effect when each user's consent was collected. Consent tied to a specific policy version — material changes may require re-consent.

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