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.
SOLVED

Regex replace to return the match instead of replace

mauricio
8 - Asteroid

Hey guys,

Is there a simple way to return a regex match instead of replacing it using the REGEX_Replace function?

 

Example

I want to return “2005” from the string “abcd_2005_12”

Match 4 digits in a row is simple: \d{4},

Match everything other than \d{4} and replace it with "" is much more difficult.

 

Thanks!

 

3 REPLIES 3
abacon
12 - Quasar

@mauricio Use the RegEx tool and use the tokenize method. This will split out to new columns the value you search for.

 

Baconimage.png

abacon
12 - Quasar

@mauricio If this worked for you, please accept it as the solution so others may find it faster.

Qiu
21 - Polaris
21 - Polaris

@mauricio 
If we have to use "REGEX_Replace" function, maybe we can do like this.

0523-mauricio.png

Labels
Top Solution Authors