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

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

joannasokolowska
9 - Comet

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
21 - Polaris

@joannasokolowska using regex tool

binuacs_0-1648276844624.png

 

joannasokolowska
9 - Comet

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
Top Solution Authors