Haven't done much with RegEx lately, so it could be that I'm just being forgetful but I would like to achieve the following:
a - one possible value for the string I search for
b - another one
c - seqence of characters I want to return
d - another possible variation of c
Normally I would do it like
(a|b)(c|d) and return the second one. However Alteryx does not allow us to have multiple matches.
a|b(c|d) looks like it's either a or b(c|d) which would be incorrect
Also how do I make conditional checks, normally I would do:
(a|b)(?c) to get a, ac, b and bc
Solved! Go to Solution.
Have you tried:
(A|B) | (C|D)
I think that this will work for you.
Thanks,
Mark
I can't remember why I got the error about only one group that can be returned? Can I find any info on that anywhere?
I don't know. But if only one group can be returned, could you execute both sets of returns as individual statements and outside of the regex function create an OR statement to combine the results into what you are looking for?
You are probably thinking of RegEx tokenize. That mode is quite tricky. I wrote a blog post about it a little while back:
http://inspiringingenuity.net/2014/06/11/alteryx-regular-expression-tokenize/
Short answer is in that mode - you do want one marked group. It helps Alteryx know what part you want to keep and wht part you don't. You can rewrite your expression:
(a|b|c|d)
If the things are complicated inside and you need to group them to have the ORs work, then you need to put them in umarked groups:
((?:a)|(?:b)|(?:c)|(?:d))