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 alternative to multiple Contains function

basub
6 - Meteoroid

Hello all,

 

I am trying to find an elegant way to convert multiple Contains function check to a single RegEx_Match function but not able to get good results. Any advise here

 

!Contains([Description],"trail")
AND
!Contains([Description],"mod")
AND
!Contains([Description],"chg")

 

Alternate:

REGEX_Match([Description],".*^[(mod),(chg),(trail)].*")

7 REPLIES 7
NicoleJohnson
ACE Emeritus
ACE Emeritus

Try this one instead!

 

REGEX_Match([Field1],".*trail.*||.*mod.*||.*chg.*")

 

The || operates as an "or" and looks for anything that contains trail, mod, or chg anywhere in the field (putting the .* on either side allows for other characters before or after the words you're searching for).

 

Hope that helps! 

 

Cheers,

NJ

jdunkerley79
ACE Emeritus
ACE Emeritus

Mine is similar to @NicoleJohnson:

 

!REGEX_Match([Description],".*(mod|chg|trail).*")

You only need a single | for alternatives in REGEX

 

NicoleJohnson
ACE Emeritus
ACE Emeritus

Oops! Thanks @jdunkerley79! Yours looks much more elegant... :)

 

NJ

MarqueeCrew
20 - Arcturus
20 - Arcturus

A similar post:  Using-IN-within-a-Contains-function

 

@jdunkerley79 and I approached it the same way.

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
basub
6 - Meteoroid

Thank you and it worked very elegantly. 

 

Any idea on how to match this string "AC Pur off lse - - AI" with my unsuccessful attempt with REGEX_Match([Description],"^(AC ).*") ?

 

The following string does gets matched but not the one above.

AC Data Comm - - AIR2

MarqueeCrew
20 - Arcturus
20 - Arcturus

does this do what you want?

 

REGEX_Match([Description],"^AC\s.*")

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
basub
6 - Meteoroid

It worked with a correction that I had to make to another exclusion condition where I had the group match (CAP) typed as [CAP].

 

Thanks !

Labels