How can I extract the string "XMLFileName" from the below URL using regular expression
var x = "C:\Documents and Settings\Dig\Desktop\XMLFileName.xml"
Thanks
You could do it with split(), pop() and replace()...
var filename = x.split('\\').pop().replace(/\..+$/, '');
You could also use a single regex...
var filename = x.replace(/.*\\|\..*$/g, '');
Ensure you escape the \ in your string literal too.
You can use: "[^\\]*$"
but why not using regular javascript functions like indexOf() etc.
[^\\]$" will match the very last character of the extension. He appears to not want the extension, and he does want more than one letter.