Alteryx Designer Desktop Discussions

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

Remove everything after the last "/" but keep this character

joannasokolowska
8 - Asteroid

Dear Colleagues,

Please advise the best Formula or Regex expression for the case below.

I would like to remove everything which is after the last "/" but keep this character.

 

Input data:

John/Kovalsky/Green234&*@oj

Anna/2012305abd

 

Desire result:

John/Kovalsky/

Anna/

 

Thank you 

Asia

5 REPLIES 5
atcodedog05
22 - Nova
22 - Nova

Hi @joannasokolowska 

 

The formula would be something like below

 

 

 

REGEX_Replace([Input], "(.*/)(.*)", "$1")

 

 

 

Regex always tries to fit in most of the characters in the initial pattern while maintaining the overall pattern. Hence all the chars before last / will be captured in first brackets(.*/). And we just need to replace the whole string with the first captured group.

 

Workflow:

atcodedog05_0-1648223887051.png

 

Hope this helps : )

 

binuacs
20 - Arcturus

@joannasokolowska using regex tool

binuacs_0-1648276844624.png

 

joannasokolowska
8 - Asteroid

Thank you both for a quick help! 

 

Asia

atcodedog05
22 - Nova
22 - Nova

Happy to help : ) @joannasokolowska 

Cheers and have a nice day!

atcodedog05
22 - Nova
22 - Nova
Labels