PCI-DSS Requirement Reference Regex for PHP
/^Req(?:uirement)?\s*([1-9]|1[0-2])(?:\.([1-9]|[1-9][0-9])(?:\.([1-9]|[1-9][0-9]))?)?$/iWhat this pattern does
This page provides a comprehensive, battle-tested regular expression for matching pci-dss requirement reference, ported and verified for PHP. In security-sensitive code, using an unverified regex can open the door to both false positives and denial-of-service attacks. 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
// PCI-DSS Requirement Reference
// ReDoS-safe | RegexVault — Security > Audit & Compliance
define('PCIDSS_REQUIREMENT_REFERENCE_PATTERN', '/^Req(?:uirement)?\s*([1-9]|1[0-2])(?:\.([1-9]|[1-9][0-9])(?:\.([1-9]|[1-9][0-9]))?)?$/');
function validate_pcidss_requirement_reference(string $input): bool {
return (bool) preg_match(PCIDSS_REQUIREMENT_REFERENCE_PATTERN, $input);
}
// Example
var_dump(validate_pcidss_requirement_reference("Requirement 3")); // bool(true)Test Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
Requirement 3 | Req 13 |
Req 3.4 | Req 0 |
Requirement 10.2.1 | Requirement 3.4.5.6 |
Req 12 | PCI 3.4 |
Requirement 6.2 | 3.4.5 |
When to use this pattern
This pattern is drawn from the Security > Audit & 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
PCI-DSS v3.2.1 and v4.0 have different requirement numbering in some sections. The mandatory effective date for v4.0 is March 31, 2025 — after which v3.2.1 is retired.
Technical Notes
PCI-DSS v4.0 (released March 2022, mandatory from March 2025) has 12 requirements. Key requirements: 3 (Protect stored cardholder data), 4 (Encrypt transmission), 6 (Develop/maintain secure systems), 10 (Log and monitor), 12 (Information security policy). v4.0 adds 64 new requirements vs v3.2.1.
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