I need to get the file name from the url.
Here are the criteria:
He needs to return the empty string "" in the following scripts:
http://somedomain.com http://www.somedomain.com http://somedomain.com/ http://www.somedomain.com/
And return filename.php in the following scripts:
http://somedomain.com/filename.php?query http://www.somedomain.com/filename.php?query http://somedomain.com/filename.php#query http://www.somedomain.com/filename.php
I found this regex
[\w_.-]*?(?=[\?\#])|[\w_.-]*$ from here
however, it returns somedomain.com at the input of http://somedomain.com . I canβt understand how to change it to ignore the domain if it isnβt at the end.
If it's hard to do with regular expressions, I will also appreciate the JavaScript solution.
Thanx in advance.
javascript url regex filenames
miki725
source share