I am trying to create a Javascript Regex that captures the filename without the file extension. I have read the other posts here and \'goto this page: http://gunbl
tested and works, even for pages without file extension.
var re = /([\w\d_-]*)\.?[^\\\/]*$/i;
var url = "http://stackoverflow.com/questions/3671522/regex-capture-filename-from-url-without-file-extention";
alert(url.match(re)[1]); // 'regex-capture-filename-from-url-without-file-extention'
url = 'http://gunblad3.blogspot.com/2008/05/uri-url-parsing.html';
alert(url.match(re)[1]); // 'uri-url-parsing'
([\w\d_-]*) get a string containing letters, digits, underscores or hyphens.
\.? perhaps the string is followed by a period.
[^\\\/]*$ but certainly not followed by a slash or backslash till the very end.
/i oh yeh, ignore case.