REGEXVAULTv2.0
Identity & PII/Health Identifiers
Verified Safe

Australian Medicare Number Regex for PHP

/^([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 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
<?php
// Australian Medicare Number
// ReDoS-safe | RegexVault — Identity & PII > Health Identifiers

define('AUSTRALIAN_MEDICARE_NUMBER_PATTERN', '/^([2-6][0-9]{9})(?:\s*([1-9]))?$/');

function validate_australian_medicare_number(string $input): bool {
    return (bool) preg_match(AUSTRALIAN_MEDICARE_NUMBER_PATTERN, $input);
}

// Example
var_dump(validate_australian_medicare_number("2123456701")); // bool(true)

Test Cases

Matches (Valid)
Rejects (Invalid)
21234567011123456701
2123456701 17123456701
6999999991212345670
2123456701121234567010
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 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

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