ISO 27001 Control Reference Regex for Go
/^(?: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 Go. 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 Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.
Go Implementation
// ISO 27001 Control Reference
// ReDoS-safe | RegexVault — Security > Audit & Compliance
package validation
import "regexp"
var iso27001ControlReferenceRe = regexp.MustCompile(`^(?:5|6|7|8)\.(?:[1-9]|[1-3][0-9]|4[0-1])(?:\.(?:[1-9]|[1-2][0-9]|30))?$`)
func ValidateIso27001ControlReference(s string) bool {
return iso27001ControlReferenceRe.MatchString(s)
}
// Example
// fmt.Println(ValidateIso27001ControlReference("5.1")) // trueTest 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 Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. 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