I tried to create a regex for this task, but I'm afraid I still can't get an intuitive understanding of regexp.
The problem is matching regular expressions to the last slash in the string. I want it to stop at the first match of the string.
My pathetic attempt to regex:
/^http(s?):\/\/.+\/{1}/
Test Subject:
http://foo.com/bar/test/foo.jpeg
The goal is to get bar/test/foo.jpegit so that I can then break the line, pull out the last element and then join the remainder, resulting in a path to the JavaScript file.
Example
var str = 'http://foo.com/bar/test/foo.jpeg';
str.replace(regexp,'');
source
share