Get File Name from a URL

function getCurrentPageName(){
	var pattern = /(.*)\/(.+?)(\.[^\.\?\#]*)[\?\#$]*/;
	var url = window.location.href;
	var result = url.match(pattern);
	console.log(result);
	if(result != null){
		return result[2] + result[3];
	}else{
		return '';
	}
}