Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Using Regex to parse before/after varying sets of digits

pmckenn
6 - Meteoroid

Have a set of addresses I am trying to parse out and am having some difficulties because there are varying number of words and digits I am looking for. Some addresses even have other names before them so I was wondering if anyone who knows Regex better than I could tell me if there was a way to elimate all words that come before a set of digits from {1,4}. 

 

For example some addresses say: "ABC Company 1234 MAIN ST" and I would like eliminate that in a way that would work with differnt company names and address #'s

 

Appreciate the help!

 

7 REPLIES 7
JordanB
Alteryx
Alteryx

Hi @pmckenn

 

I have attached a workflow using regex which seperates the company name, digits and street address. 

 

I was no sure what you meant by eliminate so seperating these into three fields can give you oppourtunity to remove the field you dont want and concatenate the fields using a formula tool. 

 

Hopefully this helps you out!

 

Best,

 

Jordan Barker

Solutions Consultant 

 

vishwa_0308
11 - Bolide

Hi,

 

 This expression "([A-Z a-z]+)(\<\d.*\>)" will eliminate your adress given "ABC Company 1234 MAIN ST" as "ABC Company" and "1234 MAIN ST". 

 

Regards

Vishwa

MarqueeCrew
20 - Arcturus
20 - Arcturus

Only a slight edit to the formula and some context:

 

I assume that you are going to create two (2) fields:  Business Name & Business Address.

 

regex_replace([Field],"([[:alpha:]]+)\s(\<\d.*\>)","$1")

That formula will give you Business Name & will eliminate the trailing space.  The $1 gets you the first grouping.  You can alter the formula for the Business Address field by replacing $1 with $2.

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
pmckenn
6 - Meteoroid

is there a way to do that with any # of digits? I should have been more clear that not every address starts with 4 digits. That expression takes any 4 digits number which sometimes would fall to the last 4 in a digit Zip code like "12345-1234" is there a way to parse any number of words before any set of digits from 1-4?

JordanB
Alteryx
Alteryx

([A-Z a-z]+)(\d*) This expression should give you everything before any sets of digits 1-4 

 

Best,

 

Jordan Barker

Solutions Consultant 

pmckenn
6 - Meteoroid

That just pulls out the number and combines the rest. Any way to turn "ABC Company Inc. 123 N. Main St. New York, NY 12345" into "ABC Comany Inc" and "123 N Main etc" ?

SophiaF
Alteryx
Alteryx

Hi @pmckenn,

 

Looks like it needed a slight modification to account for punctuation before the Street Number and to pull through the rest of the address following the Street Number: ([A-Z a-z]+\W*)(\d*.*)

 

Attached is a sample workflow with a few addresses to test.

 

Cheers,

Sophia Fraticelli
Senior Solutions Architect
Alteryx, Inc.
Labels