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

Data Subject Request (DSR) Reference Number Regex for JavaScript

/^(?: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 JavaScript. 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 JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.

Javascript Implementation

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

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

function validateDataSubjectRequestDsrReferenceNumber(input: string): boolean {
  return dataSubjectRequestDsrReferenceNumberRegex.test(input);
}

// Example
console.log(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 JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. 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