我想获取没有页面的 url。请看下面。
当前网址
http://localhost/FolderPath/Page.html
想得到
http://localhost/FolderPath/
我怎样才能做到这一点?谢谢。
我想获取没有页面的 url。请看下面。
当前网址
http://localhost/FolderPath/Page.html
想得到
http://localhost/FolderPath/
我怎样才能做到这一点?谢谢。
var oldPath = 'http://localhost/FolderPath/Page.html';
var newPath = oldPath.split('/').slice(0, -1).join('/') + '/';
"http://localhost/FolderPath/Page.html".replace(/[^\/]*$/, '');
正则表达式有人吗?
var url = "http://localhost/FolderPath/Page.html";
url.match(/(.+)(\/(.+)?)$/)[1] + "/";
//returns "http://localhost/FolderPath/"
var url = "http://localhost/FolderPath/";
url.match(/(.+)(\/(.+)?)$/)[1] + "/";
//returns "http://localhost/FolderPath/"
var url = "http://localhost/FolderPath/Page.html";
url = url.substr(0, url.lastIndexOf('/') + 1);