Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Help with a Regex

chickenlicken
8 - Asteroid

Hello, looking for some help from Regex experts

 

I am doing some text analysis..

 

It is partially working, but I end up with some contradictions and repetitions.. e.g. NOT DOG, DOG-PRESENT, or NOT CAT, CAT-PRESENT, CAT-PRESENT. 

 

The -PRESENT ones are better quality than the 'NOTS' so these should overrule them

 

I need a Regex that removes repetitions, and looks for the key word (DOG or CAT) and if -PRESENT is there, removes the NOT [KEYWORD].

 

Is this possible?

10 REPLIES 10
atcodedog05
22 - Nova
22 - Nova

Hi @chickenlicken 

Can you provide some expected output It will help us get a better understanding of the usecase.

We will be happy to help : )

chickenlicken
8 - Asteroid

So input would be NOT CAT, CAT-PRESENT, CAT-PRESENT

 

and output would be

 

CAT-PRESENT

atcodedog05
22 - Nova
22 - Nova

Hi @chickenlicken 

 

Here is how you can do it.

Workflow:

atcodedog05_0-1642674897710.png

 

Hope this helps : )

 

binuacs
21 - Polaris

@chickenlicken  are you looking for something like below

binuacs_1-1642674941764.png

 

 

chickenlicken
8 - Asteroid

Thank you, these both look like great solutions and mega quick !

chickenlicken
8 - Asteroid

Is there a way I could adjust it so that it also works where the phrases aren't in this exact order?

Input could be: 

NOT CAT, CAT-PRESENT, CAT-PRESENT

 

And also 

CAT-PRESENT, NOT CAT

 

binuacs
21 - Polaris
atcodedog05
22 - Nova
22 - Nova

Hi @chickenlicken 

 

My solution should work for any order.

 

atcodedog05_0-1642675981959.png

 

And you allowed to mark more than one posts as solution so feel free 🙂

 

Hope this helps : )

chickenlicken
8 - Asteroid

Ah nearly but not quite there yet - it's complicated because there are lots of versions of these "animals", so if there is e.g. 

 

NOT DOG, DOG-PRESENT, CAT-PRESENT, NOT CAT, MOUSE-PRESENT then it messes it up

 

How about if i change the inputs to CAT-YES, CAT-NO, DOG-YES, DOG no, etc... and then split the records multiple times....?

 

I was wondering if a Regex that looked for the matching first component would be easier...

Labels
Top Solution Authors