ISO 27001 Control Reference Regex for PHP
/^(?:5|6|7|8)\.(?:[1-9]|[1-3][0-9]|4[0-1])(?:\.(?:[1-9]|[1-2][0-9]|30))?$/What this pattern does
This page provides a well-structured, multi-part regular expression for matching iso 27001 control 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
// ISO 27001 Control Reference
// ReDoS-safe | RegexVault — Security > Audit & Compliance
define('ISO_27001_CONTROL_REFERENCE_PATTERN', '/^(?:5|6|7|8)\.(?:[1-9]|[1-3][0-9]|4[0-1])(?:\.(?:[1-9]|[1-2][0-9]|30))?$/');
function validate_iso_27001_control_reference(string $input): bool {
return (bool) preg_match(ISO_27001_CONTROL_REFERENCE_PATTERN, $input);
}
// Example
var_dump(validate_iso_27001_control_reference("5.1")); // bool(true)Test Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
5.1 | 4.1 |
5.23 | 9.1 |
6.3 | 5.42 |
7.5 | 0.1 |
8.28 | 5.1.1.1 |
8.1.1 | — |
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
ISO 27001:2013 uses the A.X.X.X control format (e.g., A.9.1.1) which is structurally different from the 2022 format. Specify the version when referencing controls. The 2022 edition has 93 controls vs 114 in 2013.
Technical Notes
ISO 27001:2022 control domains: 5 (Organizational, controls 5.1-5.37), 6 (People, 6.1-6.8), 7 (Physical, 7.1-7.14), 8 (Technological, 8.1-8.34). The 2022 update reorganized from the 2013 version's A.5-A.18 structure. Clause 4-10 are the ISMS requirements (not controls).
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