Alteryx Designer Desktop Discussions

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

New to Regex, looking for help!

rhyatt
8 - Asteroid

I've done some basic regex in Alteryx in the past, but I'm struggling with getting this to work.  Below is an example string.  What I want to do is extract the four 7 digit numbers in red.  

 

The structure of the strings will always be the same, only the 7 digit numbers will change.

 

I appreciate any help I can get! Thanks!!

 

;2945129;;;;evar23=pdp|evar30=0|evar44=product,;3673902;;;;evar23=recommendations:pdp,;3879392;;;;evar23=recommendations:pdp,;2573384;;;;evar23=recommendations:pdp

 

 

4 REPLIES 4
Claje
14 - Magnetar

This is a pretty brittle RegEx but I think it does what you need :)

;(\d\d\d\d\d\d\d);.*,;(\d\d\d\d\d\d\d);.*,;(\d\d\d\d\d\d\d);.*,;(\d\d\d\d\d\d\d);.*

If you use the Parse method in the RegEx tool it will split into four columns.

 

This specifically only works for 7 digit numbers.  You could replace the \d\d\d\d\d\d\d with \d+ if you can have different length values, as long as the semicolon and comma values always exist in the correct places.

Kenda
16 - Nebula
16 - Nebula

Hey @rhyatt!

 

I was able to extract the four sets of numbers with one Formula tool. I created 4 new fields, one for each of the sequences:

 

1st set:

REGEX_Replace([Field1], ".(\d{7}).*", "$1")

2nd set:

REGEX_Replace([Field1], ".(\d{7}).*?(\d{7}).*", "$2")

3rd set:

REGEX_Replace([Field1], ".(\d{7}).*(\d{7}).*(\d{7}).*", "$2")

4th set:

REGEX_Replace([Field1], ".(\d{7}).*(\d{7}).*", "$2")

 

rhyatt.PNG

 

 

Hope this helps!

 

danrh
13 - Pulsar

This will grab the first four 7-digit numbers in your string and put them in their own columns:

 

image.png

rhyatt
8 - Asteroid

Perfect!  Way more simple than I thought!!

Labels