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

Data Subject Request (DSR) Reference Number Regex for Go

/^(?:DSR|DSAR|SAR|RTF|RTE|REC)[\-][0-9]{4}[\-][0-9]{4,8}$/i

What this pattern does

This page provides a well-structured, multi-part regular expression for matching data subject request (dsr) reference number, ported and verified for Go. 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 Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.

Go Implementation

Go
// Data Subject Request (DSR) Reference Number
// ReDoS-safe | RegexVault — Identity & PII > Consent & Compliance

package validation

import "regexp"

var dataSubjectRequestDsrReferenceNumberRe = regexp.MustCompile(`^(?:DSR|DSAR|SAR|RTF|RTE|REC)[\-][0-9]{4}[\-][0-9]{4,8}$`)

func ValidateDataSubjectRequestDsrReferenceNumber(s string) bool {
    return dataSubjectRequestDsrReferenceNumberRe.MatchString(s)
}

// Example
// fmt.Println(ValidateDataSubjectRequestDsrReferenceNumber("DSR-2024-00001234")) // true

Test Cases

Matches (Valid)
Rejects (Invalid)
DSR-2024-000012342024-00001234
DSAR-2024-12345678DSR2024-00001234
SAR-2024-0001DSR-24-00001234
DSR-2024-ABCD

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 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

GDPR requires responding to DSARs within 30 calendar days (extendable to 90 days for complex requests, with notification). Tracking the DSR number in a workflow system is essential for compliance. Never dismiss a DSAR as spam without logging receipt.

Technical Notes

DSR reference formats: DSR=Data Subject Request, DSAR=Data Subject Access Request, SAR=Subject Access Request (UK), RTF=Right to Forget, RTE=Right to Erasure, REC=Rectification. Year prefix allows filtering by year. Sequential number ensures uniqueness.

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