Alteryx Designer Desktop Discussions

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

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. 

 

3 REPLIES 3

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
20 - Arcturus
20 - Arcturus

@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

Labels