Alteryx Designer Desktop Discussions

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

Regex Parse

FECL3
8 - Asteroid

Hi 

 

I am trying to regex parse dynamically.

 

I.e. my data is 2020 2021 Total

 

I want to pass it through the regex parse to split out the data into columns, one for each of 2020, 2021 and Total and then rename the columns dynamically. 

 

My issue is that sometimes the data can be '2021 Total' instead and so I need the second regex parse tool in the attached workflow. However when I add this, the expression is not correct as it also parses the data that is "2020 2021 Total". Instead what I want is for the data to be returned as Null because it has 2 sets of numbers in.

 

Any help on this one would be much appreciated?

2 REPLIES 2
ChrisTX
15 - Aurora

Use a website like Regex101.com to test out your regular expression.

 

ChrisTX_0-1633619812770.png

 

 

^\d{4}\s[a-zA-z]

will match 2021 Total

but will not match 2020 2021 Total

 

^\d{4}\s\d{4}\s[a-zA-z]

will do the reverse

 

Chris

Christina_H
14 - Magnetar

Instead of RegEx, could you use a Text to Columns tool?  Change the delimiter to a space and it will parse either "2020 2021 Total" or "2021 Total".  You can then rename them, and remove the null column for "2021 Total".

Labels