How can I extract a string and store it as a variable? I have this URL:
http://sub.site.com/WordsHere-t.jpg
I want to be able to able to grab just WordsHere
. It can be any length, it will not always be 9 characters. What's the best way to detect the words after the /
and before the -
?
var url = "http://sub.site.com/WordsHere-t.jpg";
var getWords = insertRegexHere(url);
document.write(getWords);
This should return the string "WordsHere"