我需要使用 javascript 隔离字符串中的 id。我已经设法到达了我到达 id 的部分,但是我希望能够将字符串的其余部分串起来,以便它只留下 id 号,如下所示:
var urlString = "http://mysite.co.za/wine/wine-blog/blogid/24/parentblogid/15.aspx";
// if the blogid is found in the url string
if (urlString.indexOf("blogid") != -1) {
alert("blogid id found");
// we strip the string to isolate the blogid
url = urlString.substring(urlString.indexOf("blogid") + 7);
//alert("url : " + url)
blogId = url.substring(0, urlString.indexOf("/"));
alert("blogId : " + blogId)
}
我需要能够在 24 岁之后剥离一切。
谢谢大家。