South Korean Resident Registration Number (RRN) Regex for JavaScript
/^(\d{2})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])-([1-4])(\d{6})$/What this pattern does
This page provides a well-structured, multi-part regular expression for matching south korean resident registration number (rrn), 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
// South Korean Resident Registration Number (RRN)
// ReDoS-safe | RegexVault — Identity & PII > National Identity Numbers
const southKoreanResidentRegistrationNumberRrnRegex = /^(\d{2})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])-([1-4])(\d{6})$/;
function validateSouthKoreanResidentRegistrationNumberRrn(input: string): boolean {
return southKoreanResidentRegistrationNumberRrnRegex.test(input);
}
// Example
console.log(validateSouthKoreanResidentRegistrationNumberRrn("880101-1234567")); // trueTest Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
880101-1234567 | 880101-5234567 |
950615-2345678 | 880001-1234567 |
010115-3456789 | 8801011234567 |
001231-4567890 | 880101-123456 |
When to use this pattern
This pattern is drawn from the Identity & PII > National Identity Numbers 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
South Korea's PIPA strictly regulates collection of RRN. Most private sector services are prohibited from collecting RRN and must use i-PIN or other alternatives. Exposure carries significant legal penalties.
Technical Notes
Structure: YYMMDD + gender/birth-year digit + 6 random digits (last is checksum). Gender/century digit: 1=male born 1900s, 2=female born 1900s, 3=male born 2000s, 4=female born 2000s (5-8 used for foreign residents). Checksum via weighted mod 11 algorithm.
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