Sign in to follow this  
Followers 0
anzacfalcon

Getting Filename from a URL

4 posts in this topic

I have a userinput which contains a full URL. Want i want to do is extract the filename from the URL and use it for something else. I was thinking String Manipulation functions would be used unless anybody knows of a better way. For example, "www.example/com/files/test.exe". What i was thinking was to somehow get the string between the last occurrence of "/" from the right and the rest of the strings to the right of it. Thanks for listening.

Share this post


Link to post
Share on other sites



I have a userinput which contains a full URL. Want i want to do is extract the filename from the URL and use it for something else. I was thinking String Manipulation functions would be used unless anybody knows of a better way. For example, "www.example/com/files/test.exe". What i was thinking was to somehow get the string between the last occurrence of "/" from the right and the rest of the strings to the right of it. Thanks for listening.

Hi,

many ways, here's one:

$string = "www.example/com/files/test.exe"
$var = StringSplit ($string, "/")
MsgBox (0,"", $var [UBound ($var) - 1])

;-))

Stefan

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank's mate. Other suggestions are welcome.

Edited by anzacfalcon

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

StringRegExpReplace ($sURL, "^.*/", "")

or:

StringTrimLeft ($sURL, StringInStr ($sURL, "/", 2, -1))

both work the same, Depends if you want to use the regex library.

Mat

Edited by Mat

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0