Data Subject Request (DSR) Reference Number Regex for PHP
/^(?:DSR|DSAR|SAR|RTF|RTE|REC)[\-][0-9]{4}[\-][0-9]{4,8}$/iWhat 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 PHP. 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 PHP project — whether you're validating in a Laravel validator, a WordPress plugin, or a standalone PHP script.
Php Implementation
<?php
// Data Subject Request (DSR) Reference Number
// ReDoS-safe | RegexVault — Identity & PII > Consent & Compliance
define('DATA_SUBJECT_REQUEST_DSR_REFERENCE_NUMBER_PATTERN', '/^(?:DSR|DSAR|SAR|RTF|RTE|REC)[\-][0-9]{4}[\-][0-9]{4,8}$/');
function validate_data_subject_request_dsr_reference_number(string $input): bool {
return (bool) preg_match(DATA_SUBJECT_REQUEST_DSR_REFERENCE_NUMBER_PATTERN, $input);
}
// Example
var_dump(validate_data_subject_request_dsr_reference_number("DSR-2024-00001234")); // bool(true)Test Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
DSR-2024-00001234 | 2024-00001234 |
DSAR-2024-12345678 | DSR2024-00001234 |
SAR-2024-0001 | DSR-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 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
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