last charters till the first slash

Hello scripters,

Can anybody help me with dividing text? I have a SMB share path and I need the
last charters till the first slash from the right side.

example:
Path: smb://myserver.com/dfs/homefolders/username in need the username

The problem is that the username has different lengths and charters. It’s not a fixed pattern.
I know you have to use text delimiters but I don’t know how.

How can help me solve this problem.

Thanks in advance.
Nils

Hello,

try something like…

set p to "smb://myserver.com/dfs/homefolders/username"
do shell script "basename " & quoted form of p
-- result: username

-- do shell script "dirname " & quoted form of p
-- result: smb://myserver.com/dfs/homefolders

Hello clemhoff

Thanks for the quick help. It works great. And simple.
Never know that basename was I part of Mac OS.

Thanks for the help.

Nils

And the plain AppleScript way:

set p to "smb://myserver.com/dfs/homefolders/username"
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set q to last text item of p
set AppleScript's text item delimiters to ASTID
return q