LogoReturn to Home RegEx
Integrations
All integrations
AWS API
AWS Lambda
DynamoDB
Oracle
Redshift
Snowflake
GraphQL
Supabase
Twilio
Azure Blob Storage
Slack
SendGrid
Generic HTTP API
AWS S3
Stripe
Microsoft SQL
Salesforce
PostgreSQL
MySQL
MongoDB
HubSpot
Google Sheets
Google BigQuery
Firebase
Airtable
Integrations
About UI Bakery
Log in
Request UI Bakery demo
RegEx library
Email regex C#
Phone number regex C#
IP address regex C#
Date regex C#
URL regex C#
Numbers only regex (digits only) C#
UUID regex C#
Regex match words C#
ZIP code regex C#
GUID regex C#
Password regex C#
HTML regex C#
SSN regex C#
XML regex C#
Mac address regex C#
Street address regex C#

Street address regex C#

Usually, it’s a bad idea to validate street addresses using regular expressions (read below). But in some cases it might make sense and here’s a regular expression that can help with that

Discover UI Bakery – an intuitive visual internal tools builder. Try it now!
JavaScript
Python
Java
C#
PHP

Simple address regex

Below is a regex that check for a pattern: Addr# Street Name, City, State ZIP code

new Regex("^(\\d{1,}) [a-zA-Z0-9\\s]+(\\,)? [a-zA-Z]+(\\,)? [A-Z]{2} [0-9]{5,6}$")
Test it!
/^(\d{1,}) [a-zA-Z0-9\s]+(\,)? [a-zA-Z]+(\,)? [A-Z]{2} [0-9]{5,6}$/

True

False

Enter a text in the input above to see the result

Example code in C#:

using System.Text.RegularExpressions;
using System.Linq;
using System;
                    
public class Program
{
    public static void Main()
    {
        // Validate street address
        Regex validateStreetAddressRegex = new Regex("^(\\d{1,}) [a-zA-Z0-9\\s]+(\\,)? [a-zA-Z]+(\\,)? [A-Z]{2} [0-9]{5,6}$");
        Console.WriteLine(validateStreetAddressRegex.IsMatch("3344 W Alameda Avenue, Lakewood, CO 80222"));  // prints True
    }
}
Test it!

True

False

Enter a text in the input above to see the result

Test it!

True

False

Enter a text in the input above to see the result

Notes on street address regex validation

Validating an address with a regex is usually a bad idea because of the way how address is written in different parts of the world. Usually, it’s better to just check that the address is not empty and let the user enter what do they want. Another way would be to use a third-party library like Google Places API which will convert information a user entered in a unique ID that would identify that address.

Create an internal tool with UI Bakery

Discover UI Bakery – an intuitive visual internal tools builder.

Try it now