Extracting Addresses

Hi! I'm trying to pull addresses from a form, but the wording changes every time so I'm not sure if it's possible. Any ideas of how to automate this process? The information is always in two cells of the chart.

Two example formats:
STORE NAME #11 STATE UNIV BKST 1111 EXAMPLE STREET CITY NAME STATE ABBREVIATION ZIP CODE

First Name Last Name, 1111 Street Name, Building Room Number 111, (123)-123-1234, email.address@college.edu

Here's what I have so far. The city, state, and zip Code are in separate cell on the chart, so if necessary I can copy one cell at a time to get the address, which is what I've done here.

Thanks!

{=clipboard_data}{clipboard_data={clipboard}}
{state_abbreviation=extractregex(clipboard_data, "\b[A-Z]{2}\b")}
{City=extractregex(clipboard_data, "(.+\b) \w+\s\b\d{5}\b")}
{zip_code=extractregex(clipboard_data, "\b\d{5}\b")}
{Name=extractregex(clipboard_data, "\w+ \w+")}
{Street=extractregex({clipboard}, "\d+ .+")}
{Follett=extractregex({clipboard}, "FOLLETT STORE #\d+")}
{if: testregex({clipboard},"FOLLETT")}{=follett}{else}{=name}{endif}
{=street}
{=City}
{=state_abbreviation}
{=zip_code}

Hi @shipping,

Welcome to the forum :slightly_smiling_face:

If you are getting information from a webpage, you can use our {site} command to read the addresses directly instead of copying them to the clipboard and extracting the relevant information. Please let me know if you have any further questions.

Unfortunately, the forms are on a document, not a webpage :slightly_frowning_face:

Okay, so in that case I think you are in the direction if you want to automate it. Can you please provide an example where you snippet is not working currently?

If I copy this address to my clipboard:

FOLLETT STORE #111 1234 BKST 123 Street Name City Name MI 12345

I get this:

FOLLETT STORE #111
111 1234 STATE UNIV BKST 123 Street Name City Name State Abbreviation 12345
FOLLETT STORE #111 1234 STATE UNIV BKST 123 Street Name City Name State
MI
12345

Ideally, I'd like the bookstore, street, city, etc pulled individually rather than in one long string. Is that possible?

I attempted to extract the street and city names by eliminating the zip_code, follett, state_abbreviation, and a portion of the address using our {replace} and {replaceregex} functions. Although I successfully achieved this, I encountered difficulty in distinguishing between the street name and city name without a unique separator.

{=clipboard_data}{clipboard_data={clipboard}}
{state_abbreviation=extractregex(clipboard_data, "\b[A-Z]{2}\b")}
{City=extractregex(clipboard_data, "(.+\b) \w+\s\b\d{5}\b")}
{zip_code=extractregex(clipboard_data, "\b\d{5}\b")}
{Name=extractregex(clipboard_data, "\w+ \w+")}
{Street=reduced_data}
{Follett=extractregex(clipboard_data, "FOLLETT STORE #\d+")}
{reduced_data=replaceregex(replace(replace(replace(clipboard_data, zip_code, ""), follett, ""), state_abbreviation, ""), "\d+ \S+ \d+ ", "")}{=reduced_data}

Store name: {if: testregex({clipboard},"FOLLETT")}{=follett}{else}{=name}{endif}
Street: {=street}
City: {=City}
State: {=state_abbreviation}
ZIP code: {=zip_code}