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?
Solved! Go to Solution.
Use a website like Regex101.com to test out your regular expression.
^\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
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".