REGEXVAULTv2.0
Identity & PII/Location PII
Verified Safe

Street Address (US Format) Regex for Python

/^[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 Python. 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 Python project — whether you're validating in a Django view, a FastAPI endpoint, or a standalone data processing script.

Python Implementation

Python
# Street Address (US Format)
# ReDoS-safe | RegexVault — Identity & PII > Location PII

import re

street_address_us_format_pattern = re.compile(r'^[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))?\.?$')

def validate_street_address_us_format(value: str) -> bool:
    return bool(street_address_us_format_pattern.fullmatch(value))

# Example
print(validate_street_address_us_format("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 Python developers because particularly important in Python web servers where CPU-bound regex operations can stall concurrent request handling. 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