community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

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

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!

Highlighted
Alteryx Certified Partner
Alteryx Certified Partner

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,

How about:

 

FileGetFileName([FullPath])

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

 

Asteroid

Awesome, good thing to know.

 

Thanks!

Labels