Alteryx Designer Desktop Discussions

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

RegexReplace function

Chirag_KRCPL
8 - Asteroid

Field1 is the input in below snip:

Chirag_KRCPL_0-1662455547660.png

I have encircled the output

I want the output using Regex_replace(String,Pattern,Replace) function.

Basically I want 2 characters that lie on the either side of the backslash "/" along with the backlash

5 REPLIES 5
IraWatt
17 - Castor
17 - Castor

Hey @Chirag_KRCPL,

There is definitely a cleaner regex formula then this but here is one way:

IraWatt_0-1662456088365.png

Essentially it uses three parts:

match any non space character

[^\s]+

 match a space character

\s

match a forward slash

\/

If you want to learn more about Regex the community has some really quick interactive videos on getting to grips with it here https://community.alteryx.com/t5/Interactive-Lessons/tkb-p/interactive-lessons/label-name/Parsing%20...

 

Any questions or issues please ask

Ira Watt
Technical Consultant
Watt@Bulien.com 

 

Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @Chirag_KRCPL,

 

You could use the following piece of Regex to extract it, the $1 essentially calls the first capture group. Therefore overwriting the entire text string with just what is contained in the capture group.

 

REGEX_Replace([Field1], '.*(\S+\s+\S+\s+\/\s+\S+\s+\S+).*$', '$1')

 

 

JonathanSherman_0-1662456416201.png

 

I've attached an updated workflow!

 

Kind regards,

Jonathan

 

Jonathan-Sherman
15 - Aurora
15 - Aurora

@IraWatt I took a similar approach to you, but using \S rather than [^\s] to call non whitespace characters 😎

IraWatt
17 - Castor
17 - Castor

@Jonathan-Sherman of course ! 😅 always forget \S is a thing...

Emmanuel_G
13 - Pulsar

Hi @Chirag_KRCPL ,

 

Find attached a way to do that with regex_replace function.

 

Let me know if there is any issue.

 

Emmanuel_G_0-1662497689299.png

 

Labels