Alteryx Designer Desktop Discussions

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

Regex: Remove everything except a specific pattern

Pablo_Sahonero
5 - Atom

Hi i been looking for some hours in internet but i didn't figure out this problem yet

i have some records like this:

 

Random KEY1 Text KEY3

Blah Blah KEY10

Hello World KEY5

KEY22 another text KEY1

 

And my desired result is this:
KEY1 KEY3

KEY10

KEY5

KEY22 KEY1

 

basically i want to remove everything in a string except these KEY ID's

 

Thanks

6 REPLIES 6
ChrisTX
16 - Nebula
16 - Nebula

Can you provide some actual input data, mocked up if necessary?   Does the text you want actually include the work KEY in all caps, followed by one or more numbers?

 

Chris 

Emmanuel_G
13 - Pulsar

Hi @Pablo_Sahonero ,

 

Find attached the way of doing this with simple Regex expression : (KEY\d+?)

 

Let me know if there is any issue.

 

Please do not hesitate to mark this answer as solution if it helped.

 

Emmanuel_G_1-1663600213182.png

 

binuacs
21 - Polaris

@Pablo_Sahonero Are you looking for something like below

 

binuacs_0-1663600312130.png

 

Pablo_Sahonero
5 - Atom

yes KEY is always going to be in capital followed by a number

Pablo_Sahonero
5 - Atom

thanks for the responses
the solutions indeed "works" but the problem is i can have more than 2 occurrences within a single record
you may say ok split it in more columns BUT i don't know how many occurrences can be
it's there a way of using regex replace instead of tokenize?
EDIT: i tried using replace with the regexs provided but i get the opposite that i wanted:

 

screen

binuacs
21 - Polaris

@Pablo_Sahonero Try the below regex

 

binuacs_0-1663604046445.png

 

Labels
Top Solution Authors