A function similar to "before(" function but starting at the right hand side of a string

A function similar to "before(" function but starting at the right hand side of a string

Is there a function that works like the before( function but starts looking for the tag at the end of the string working left?

I am working on a procedure that usually opens a document when referencing the path with the “openanything PATH” statement. That is a cinch.

However, if I want to open the folder instead of the document I have to trim from the right end of the path string left to the last trailing “/” or forward slash in the string.

The end result would be two procedures, one “Open Document” and the other “Open Folder” using the same data, one intact and the other trimmed of the document name.

The before( function does not work because depending on the number of slashes in the path it looks like I am destined for a heart pounding exercise with Text Funnels.

I know conceptually how to do that but want to avoid it if possible.


Are you familar with the - option? VariableName[“-/”,-1]

Using text funnels, you can use

openanything PATH[1,"-/"]

or you can use arrayrange(

openanything arrayrange(PATH,1,-2,"/")

No I am not Robert. I’ll check it out. Thanks.

Thanks Dave.

I’ll give it a go.

I am not sure I understand Robert.

This is what I did that works perfectly, as Dave recommended

if info("modifiers") contains "Option"
openanything «Open File Folder»[1,"-/"]
openanything «Open File Folder»

I tried this:

Openanthing «Open File Folder»[“-/”,-1]

It does not work. I get an error.

Thanks for answering what turned out to be a rather basic question.


[“-/”,-1] will return everything from the last slash to the last character, trimming everything that comes before it. So it was trimming the part you wanted to keep, and keeping the part you wanted to trim.

A third option, I thought of after I posted earlier, would be to use the arraytrim( function.

Thanks again Amigo.

Or you can simply use the revealinfinder statement.

I think Kurt’s idea of revealinfinder is probably perfect for your application.

However, if you really do want to do this string manipulation, I believe the filepath( function does exactly what you need.

So now I think you have 3 or 4 ways to do this! :slight_smile:

Close this down Jim before I have another half dozen solutions!

There is more than one way to solve as Pan X challenge.

Many more!