REGEXVAULTv2.0
Localization/Phone Numbers
Verified Safe

Australian Phone Number Regex for Go

/^(?:\+61|0)(?:\s|-)?(?:[2-578])(?:[\s.-]?[0-9]{4}){2}$|^(?:\+61|0)4[0-9]{2}(?:[\s.-]?[0-9]{3}){2}$/

What this pattern does

This page provides a comprehensive, battle-tested regular expression for matching australian phone number, ported and verified for Go. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. 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 Phone Number
// ReDoS-safe | RegexVault — Localization > Phone Numbers

package validation

import "regexp"

var australianPhoneNumberRe = regexp.MustCompile(`^(?:\+61|0)(?:\s|-)?(?:[2-578])(?:[\s.-]?[0-9]{4}){2}$|^(?:\+61|0)4[0-9]{2}(?:[\s.-]?[0-9]{3}){2}$`)

func ValidateAustralianPhoneNumber(s string) bool {
    return australianPhoneNumberRe.MatchString(s)
}

// Example
// fmt.Println(ValidateAustralianPhoneNumber("+61 2 9374 4000")) // true

Test Cases

Matches (Valid)
Rejects (Invalid)
+61 2 9374 4000+61 0 1234 5678
02 9374 40000192 345 678
+61412345678+61 2 1234 567
0412 345 67802 9374 40000
+61 8 9321 0000

When to use this pattern

This pattern is drawn from the Localization > Phone Numbers 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

Australia's 10-digit numbers (2 area code + 8 local) replaced the older variable-length system in the late 1990s. Historical data may have shorter numbers.

Technical Notes

Australian area codes: 02 (NSW/ACT), 03 (VIC/TAS), 07 (QLD), 08 (SA/WA/NT). Mobile numbers start with 04 (04xx = 10-digit mobile). 05 is reserved. +61 replaces the leading 0.

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