REGEXVAULTv2.0
Identity & PII/National Identity Numbers
Verified Safe

Malaysian IC Number (MyKad / NRIC) Regex for JavaScript

/^(\d{2})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])-(0[0-9]|1[0-6])-(\d{4})$/

What this pattern does

This page provides a well-structured, multi-part regular expression for matching malaysian ic number (mykad / nric), 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
// Malaysian IC Number (MyKad / NRIC)
// ReDoS-safe | RegexVault — Identity & PII > National Identity Numbers

const malaysianIcNumberMykadNricRegex = /^(\d{2})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])-(0[0-9]|1[0-6])-(\d{4})$/;

function validateMalaysianIcNumberMykadNric(input: string): boolean {
  return malaysianIcNumberMykadNricRegex.test(input);
}

// Example
console.log(validateMalaysianIcNumberMykadNric("880101-14-5555")); // true

Test Cases

Matches (Valid)
Rejects (Invalid)
880101-14-5555880101145555
990231-10-1234880101-17-5555
010115-01-0001880001-14-5555
001231-12-9999880132-14-5555
8801014-14-555

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

The MyKad encodes date of birth and gender directly in the number — exposure of the IC number reveals both. Foreigners use a different format with different state codes (60-93 for foreign workers).

Technical Notes

Structure: YYMMDD (date of birth) + state code (01-16) + sequential number. Last digit odd=male, even=female. State codes: 01=Johor, 02=Kedah, ..., 14=Federal Territory, 15=Sabah, 16=Sarawak. YYMMDD does not validate day-of-month correctness (e.g., 990231 is Feb 31).

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