REGEXVAULTv2.0
Identity & PII/Health Identifiers
Verified Safe

Australian Medicare Number Regex for Go

/^([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 Go. 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 Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.

Go Implementation

Go
// Australian Medicare Number
// ReDoS-safe | RegexVault — Identity & PII > Health Identifiers

package validation

import "regexp"

var australianMedicareNumberRe = regexp.MustCompile(`^([2-6][0-9]{9})(?:\s*([1-9]))?$`)

func ValidateAustralianMedicareNumber(s string) bool {
    return australianMedicareNumberRe.MatchString(s)
}

// Example
// fmt.Println(ValidateAustralianMedicareNumber("2123456701")) // 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 Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. 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