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

Regex help to parse out data with a set pattern

heatherreid70
7 - Meteor

I have a data set that has a column with junk data surrounding the data I need.  

 

Example:  RS345, WIhihdh, 19-999878  or

 

D124, 18-878789 RT2A

 

I need to keep only the 19-000989 or the 18-878789.   I need to create a string expression that will look for xx-xxxxxx  and create a new column for this data.

 

I'm trying to use the multi-row formula tool I'm struggling with the string expression.  Any advice would be appreciated.

 

 

4 REPLIES 4
Blake
12 - Quasar

Hi @heatherreid70 

 

Try this and let me know if it works for you. 

 

Blake_0-1586189390222.png

 

 

 

 

heatherreid70
7 - Meteor

this works like a charm!  thank you so much

AshleenKenney
7 - Meteor

 Hi Blake,

Thank you for your solution I found it very helpful as well.  However, in my case the field may contain the same pattern .*(\d{2}-\d{6}).* more than once and I would like every instance of the pattern parsed/returned.  How would I change the expression to account for multiple instances?

Thanks

Blake
12 - Quasar

Hey @AshleenKenney 

 

I'm glad the previous solution helped you! 

 

If you have multiple IDs in the fields, you can parse each one out by using the tokenize method rather than parse. 

 

If you have a variable number of IDs, I would recommend putting a RecordID right before your Regex tool and parsing to rows. This will put each ID on a separate line but let you know which record it came from. 

 

If you have a static number of IDs, you can just select that number of columns to parse to. 

 

AK.png

 

I've attached a sample canvas to this comment, let me know if it works for you! 

 

 

Labels