Australian Medicare Number Regex for JavaScript
/^([2-6][0-9]{9})(?:\s*([1-9]))?$/What this pattern does
This page provides a well-structured, multi-part regular expression for matching australian medicare 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
// Australian Medicare Number
// ReDoS-safe | RegexVault — Identity & PII > Health Identifiers
const australianMedicareNumberRegex = /^([2-6][0-9]{9})(?:\s*([1-9]))?$/;
function validateAustralianMedicareNumber(input: string): boolean {
return australianMedicareNumberRegex.test(input);
}
// Example
console.log(validateAustralianMedicareNumber("2123456701")); // trueTest Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
2123456701 | 1123456701 |
2123456701 1 | 7123456701 |
6999999991 | 212345670 |
21234567011 | 21234567010 |
| — | 2123456701A |
When to use this pattern
This pattern is drawn from the Identity & PII > Health Identifiers 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 IRN distinguishes family members sharing a Medicare card. When storing, preserve both the 10-digit number and the IRN — the full reference is: XXXXXXXXXX/1 (where 1 is the cardholder, 2-9 are dependants).
Technical Notes
Australian Medicare numbers start with 2-6 (4=concessional). 10-digit number + 1-digit IRN (Individual Reference Number, 1-6, identifies individuals on a family card). Checksum: weighted sum of first 9 digits, compare to 10th. Services Australia assigns and validates.
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