jQuery正则表达式从url获取

jQuery正则表达式从url获取,jquery,regex,Jquery,Regex,我阅读了regex文档,但不明白如何实现我想要的 我有urlehttp://testhermes.tumblr.com/post/108728110699/hermes-instagram-photo-sit-back-and-relax?index=1像这样,我想在post“108728110699”和index=“1”后面加上数字 你能帮帮我吗。 谢谢。 var url=”http://testhermes.tumblr.com/post/108728110699/hermes-instag

我阅读了regex文档,但不明白如何实现我想要的

我有urle
http://testhermes.tumblr.com/post/108728110699/hermes-instagram-photo-sit-back-and-relax?index=1
像这样,我想在post“108728110699”和index=“1”后面加上数字

你能帮帮我吗。 谢谢。

var url=”http://testhermes.tumblr.com/post/108728110699/hermes-instagram-photo-sit-back-and-relax?index=1";
url=url.match(/\d+/g);
警报(url[0])//108728110699
警报(url[1])//1

window.location.search为您提供了查询字符串以及如何单独获取这些数字?请查看更新的答案非常感谢:)欢迎@AramMkrtchyan