Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 662169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:20:54+00:00 2026-05-13T23:20:54+00:00

I am trying to extract a US address from a text. So if I

  • 0

I am trying to extract a US address from a text.

So if I have the following variations of text then I’d like to extract the address portion

Today is a good day to meet up at a
bar. the address is 123 fake street,
NY, 23423-3423

 just came from 423 Elm Street, kk, 34223 ...had awesome time

blah blah bleh blah 23414 Fake Terrace, MM something else

 experimented my teleporter to get to work but reached at 2423 terrace NY

If someone can provide some starting points then I can mold it for other variations.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:20:55+00:00Added an answer on May 13, 2026 at 11:20 pm

    At some point, you’d have clarify what you consider an address to be.

    Does an address just have a street number and street name?

    Does an address have a street name, and a city name?

    Does an address have a city name, a state name?

    Does an address have a city name, a state abbreviation, and a zip code? What format is the zip code in?

    It’s easy to see how you can run into trouble quickly.

    This obviously wouldn’t catch everything, but maybe you could match strings that start with a street number, has a state abbreviation in the middle somewhere, and end in a zip code. The reliability of this would greatly depend on knowing what sort of text you were using as the input. I.e., if there is a lot of other numbers in the text, this could be completely useless.

    possible regex

    \d+.+(?=AL|AK|AS|AZ|AR|CA|CO|CT|DE|DC|FM|FL|GA|GU|HI|ID|IL|IN|IA|KS|KY|LA|ME|MH|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|MP|OH|OK|OR|PW|PA|PR|RI|SC|SD|TN|TX|UT|VT|VI|VA|WA|WV|WI|WY)[A-Z]{2}[, ]+\d{5}(?:-\d{4})?
    

    sample input

    hello world this is me posting an address. please go to 312 N whatever st., New York NY 10001.
    
    If you can find me there. I might be at 123 Invalid address.
    
    Please send all letters to 115A Address Street, Suite 100, Google KS, 66601
    
    42 NE Another Address, Some City with 9 digit zip, AK 55555-2143
    
    Hope this helps!
    

    matches

    312 N whatever st., New York NY 10001
    115A Address Street, Suite 100, Google KS, 66601
    42 NE Another Address, Some City with 9 digit zip, AK 55555-2143
    

    regex explanation

    \d+                      digits (0-9) (1 or more times (matching the most amount possible))
    .+                       any character except \n (1 or more times (matching the most amount possible))
    (?=                      look ahead to see if there is:
      AL|AK|AS|...             'AL', 'AK', 'AS', ... (valid state abbreviations)
    )                        end of look-ahead
    [A-Z]{2}                 any character of: 'A' to 'Z' (2 times)
    [, ]+                    any character of: ',', ' ' (1 or more times (matching the most amount possible))
    \d{5}                    digits (0-9) (5 times)
    (?:                      group, but do not capture (optional (matching the most amount possible)):
      -                        '-'
      \d{4}                    digits (0-9) (4 times)
    )?                       end of grouping
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract information from an email address like so in ruby: Email:
I'm trying to extract all matches from a EBML definition, which is something like
I'm trying to extract the URL from the address bar of IE. (IE 8
Im trying to extract a YouTube link from just random text. e.g. This is
I am trying to extract duplicate rows from my database. I have a listings
I'm trying to extract email addresses from plain text transcripts of emails. I've cobbled
I am trying to extract the string from a file having following pattern within
I am trying to extract text from body downloaded via ajax. I can not
Im trying to extract a line from wget's result but having trouble with it.
I am trying to extract a table of values from an excel (2003) spreadsheet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.