Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

REGEX_Replace function

cmohyi
7 - Meteor

Hi, 

 

I've searched various posts but couldn't find an answer that worked. I have a string of data, "1/FundName-Class", and I want to extract everything left of the / using regex_replace. The numbers go from 1-47000 so a LEFT function won't work. Any help is appreciated. 

5 REPLIES 5
Kenda
16 - Nebula
16 - Nebula

Hey @cmohyi!

 

When you want to use a symbol in a regex statement, put a \ before it. Below I created two new fields, one that keeps everything before your slash and one that keeps everything after the slash. Remember, this assumes you only have one slash in your Field1.

 

regex replace slash.PNG

MarqueeCrew
20 - Arcturus
20 - Arcturus

@cmohyi,

 

Here's 2 alternative solutions (I do see that @Kenda has answered while I was playing with your post):

 

REGEX_Replace([Field1], "(.*)\/.*", '$1')
left([Field1],FindString([Field1], "/"))

The first function will take anything left of the "last" / and provide you with that value.

The second function will take the leftmost characters that it finds before the first /.

 

Cheers,

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
cmohyi
7 - Meteor

@barnesk @marqueecrew Thank you both!

Gamaliel
10 - Fireball

Hello @Kenda .What if there are more than 2 slashes found? What expression should be used to delimit them to more than 2 columns. Thank you

apathetichell
18 - Pollux

Hi - this is a fairly old thread. Post some examples of your regex problem in a new thread and I'm sure someone can help you...

Labels