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

Second to Last Occurrence of character

NidhiAg
7 - Meteor

Hi Team

I have a varying folder structure \\Folder\Test\Test1\Test2\.......\2021\06. Jun\09\Test.xlsx

 

I need to get it trimmed to last sec occurrence of '\' and get me output as

\\Folder\Test\Test1\Test2\.......\2021\06. Jun

 

I can use reversestring, Findstring but its getting very lengthy .Any quicker way of doing this

3 REPLIES 3
Luke_C
17 - Castor
17 - Castor

Hi @NidhiAg 

 

I want to caveat that I'm not a regex expert, but the below looks to work in regex parse mode. 

 

(.*)\\.*\\.*

 

Luke_C_0-1623255147099.png

 

 

NidhiAg
7 - Meteor

Didnt work with my actual path. Can you please explain me the Regex.

Update : my Path can vary and all i want to get path excluding FileName and last folder

 

Luke_C
17 - Castor
17 - Castor

Hi @NidhiAg 

 

You might need to increase the size of the field in the regex tool. I just tried with a few different paths and it seems to work, but some longer paths were truncated until I increased the size.

 

(.*)\\.*\\.*

 

(.*): All characters

\\.*: All characters after a \

 

The parenthesis indicates what we're outputting. In this case all characters before it sees two slashes (and anything after those 2 slashes).

 

 

Labels