Strip everything in front of character X

Hi everyone!

I’ve tried for a long time, but I can’t seem to work out how I would strip (or trim) all the characters in front of a certain character. See this example:

set stringA to "directory/directory/directory/file.suffix"

Now I want to strip all the characters that are in front of the last slash and the slash itself. The outcome should be like this:

set stringB to "file.suffix"

I’ve tried setting the string into individual characters, reversing the whole string and then finding the first item. But in both cases, my problem is that I don’t know how to get the position of the last (or first) slash so that later I can just:

set stringC to text (positionOfLastSlash + 1) thru -1

If someone could help me out, then that would be really great! Appreciate it! :smiley:

Regards,

Max

set stringA to "directory/directory/directory/file.suffix"

set AppleScript's text item delimiters to "/"
set thetemplist to stringA's text items
set stringB to the last item of thetemplist

set AppleScript's text item delimiters to ""

Thank you very much! :cool: