REGEXVAULTv2.0
Identity & PII/Location PII
Verified Safe

Street Address (US Format) Regex for Go

/^[0-9]{1,6}(?:\s+(?:apt|unit|ste|suite|#)\s*[A-Za-z0-9]+)?\s+[A-Za-z0-9\s.'-]{3,50}(?:\s+(?:ave|avenue|blvd|boulevard|ct|cir|dr|drive|hwy|highway|ln|lane|pkwy|parkway|pl|place|rd|road|st|street|ter|terrace|trl|trail|way))?\.?$/i

What this pattern does

This page provides a comprehensive, battle-tested regular expression for matching street address (us format), 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
// Street Address (US Format)
// ReDoS-safe | RegexVault — Identity & PII > Location PII

package validation

import "regexp"

var streetAddressUsFormatRe = regexp.MustCompile(`^[0-9]{1,6}(?:\s+(?:apt|unit|ste|suite|#)\s*[A-Za-z0-9]+)?\s+[A-Za-z0-9\s.'-]{3,50}(?:\s+(?:ave|avenue|blvd|boulevard|ct|cir|dr|drive|hwy|highway|ln|lane|pkwy|parkway|pl|place|rd|road|st|street|ter|terrace|trl|trail|way))?\.?$`)

func ValidateStreetAddressUsFormat(s string) bool {
    return streetAddressUsFormatRe.MatchString(s)
}

// Example
// fmt.Println(ValidateStreetAddressUsFormat("123 Main St")) // true

Test Cases

Matches (Valid)
Rejects (Invalid)
123 Main StMain St
456 Elm Avenue123
789 Oak BlvdJust A Name
1000 Willow Lane Apt 5B
1 Infinite Loop
123 Main

When to use this pattern

This pattern is drawn from the Identity & PII > Location PII 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

Address validation regex cannot verify that an address is deliverable. Use USPS CASS-certified address validation for mail delivery. For geocoding, use a geocoding API (Google Maps, Here).

Technical Notes

US addresses are extremely varied — this pattern covers the most common format but not all. PO Boxes, rural routes, and military addresses require different patterns. Use a dedicated address validation API (USPS, SmartyStreets) for reliable validation.

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