Alteryx Designer

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

REGEX PARSE FILE PATH

Highlighted
5 - Atom

I'm trying to parse the part of a file path that comes after the last backward slash. So for example, C:\1\2\3\4 would return "4".  I found an expression on RegexPal that worked there, but not in Alteryx. It is: ([^\\\\]+$)

 

When I try this in Alteryx, it returns null. What is the Alteryx version of this? 

Thanks. 

 

Highlighted
Alteryx Alumni (Retired)

As a suggestion...

I'm not that great at RegEx, so if I had a file path, I would use the Formula tool and the FileGetFileName function in an expression. :smileyhappy:

Highlighted
Alteryx Alumni (Retired)

But this seems to work for your example...

 

.*\\(.+?)

Highlighted
5 - Atom

I changed it to .*\\(.+$) and it almost works, except i have the final slash at the end. 

Highlighted
5 - Atom

my original example should have been c:\1\2\3\4\ and i want "4". 

any idea how I delete the final "\"? 

 

Highlighted
Alteryx Alumni (Retired)

Just add another "\" (with the escape character)...

 

.*\\(.+?)\\

Labels