Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

RegEx - multiple "OR"

dawid_nawrot
9 - Comet

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

4 REPLIES 4
MarqueeCrew
20 - Arcturus
20 - Arcturus

Have you tried:

 

(A|B) | (C|D) 

 

I think that this will work for you.

 

Thanks,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
dawid_nawrot
9 - Comet

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?

MarqueeCrew
20 - Arcturus
20 - Arcturus

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?

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Ned
Alteryx Alumni (Retired)

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))
Labels