Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Find the nth occurrence of a string and replace the Right of string with ""

aparanjith1
8 - Asteroid

Hi,

I have a User input path which will have a Folder_Name at the end of the path as shown below;

C:\Users\r628953\Desktop\09-25-2018_Sample_files

 

So, I need to find the last occurrence of "\" in the above path and replace the right of the string with "". So, that I will get the folder name out of the string; which will be  09-25-2018_Sample_files. I have researched about it, but could not able to get the exact answer I am looking for.

Can some one help me in achieving this?

 

Thanks!

3 REPLIES 3
Thableaus
17 - Castor
17 - Castor

Hi @aparanjith1 

 

I'm not sure if I got what you meant, but if you need to extract the last part I'd recommend you to use a Regex Expression.

 

REGEX_Replace([Field1], ".*\\(.+)", "$1")

 

If you need to replace the last expression, you could change it to REGEX_Replace([Field1], "(.*\\)(.+)", "$1replacementstring"), replacement string being what you want to put it there..

 

Cheers,

jdunkerley79
ACE Emeritus
ACE Emeritus

How about:

 

FileGetFileName([FullPath])

2019-01-25_16-28-25.jpg

 

aparanjith1
8 - Asteroid

Awesome, good thing to know.

 

Thanks!

Labels