We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Parse Zip code with Regex.

lbolin
8 - Asteroid

I am trying to parse and address to pull out the zip code from and address and it have written this regex \s(\d{5}[^a-zA-Z]*)\s and it works perfect until I hit an address that has a house number that matches that pattern.

 

Example:

David Rose PO Box 31741 Little Rock, Arkansas 72148 Unites States
74168 River Bend Road Searcy, Arkansas 72149 United States

 

I don't know if there a work around or if that is just something i just have to live with. 

 

5 REPLIES 5

Hi @lbolin 

 

Is it safe to say that the "," will always be included? 

 

Option1:

.*,.*(\d{5}).*

 

If it will always end with United States (one record is misspelling United)  so perhaps this could work

 

Option 2:

(\d{5})\s\w+\s\w+$

Qiu
21 - Polaris
21 - Polaris

@lbolin 
Agree with @christine_assaad , we need a flag to differ the zip code with other five digits number.

Or try a hard way, Use Find and Replace with Zip Code list.

http://phaster.com/zip_code.html

Qiu_0-1608070714874.png

 

PhilipL
Alteryx
Alteryx

Hi @lbolin 

 

If the data always ends with "United States" you could use GetWord to isolate the Zipcode. 

Getword ([Full Address], CountWords([Full Address])-3)

 
 
 
 

Capture.PNG

JPSeagull
8 - Asteroid

5 years later and Option 1 was the perfect solution for me with a mix of full addresses using either 5 digits or the 5+4 and it saved me the extra step to reduce it to 5 digit! Thanks!

Gaurav_Dhama_
12 - Quasar

I did not realise it was 5 year old until i read the comment 😂.

Labels
Top Solution Authors