I want to extract the base name from a image URL in Javascript. Would somebody care to give me a a hand on the Regex?
The rule would be:
return ever
I wouldn't actually use a regex in this case, but simply lastIndexOf and substring. Something like
lastIndexOf
substring
function findBaseName(url) { var fileName = url.substring(url.lastIndexOf('/') + 1); var dot = fileName.lastIndexOf('.'); return dot == -1 ? fileName : fileName.substring(0, dot); }