Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
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
13 - Pulsar

@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
13 - Pulsar

@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