url = ?http://1dwen.cn/index.php/joi...“
Wie verwende ich einen regul?ren Ausdruck, um den Wert 22 nach uid abzugleichen? Kann mir ein Experte helfen?
'http://1dwen.cn/index.php/uid/22/join/team_list?share_text=3&share_pic=12'.match(/http:\/\/1dwen\.cn\/index\.php\/uid\/(\d+)/)[1]
var url = new URL("http://1dwen.cn/index.php/join/team_list/uid/22?share_text=3&share_pic=12");
var pathname = url.pathname;
var reg = /\d+$/gi;
var result = pathname.match(reg);
js 或者 java的話用indexOf和subString之類的方法就可以搞定
var index = 'asdf'.indexOf('s') ;// ---> 1
'asdf'.substring(index); //....
如果是用正則表達(dá)式(js版),可以使用正則表達(dá)式分組:
t = /uid\/(.*)\?/.exec('http://1dwen.cn/index.php/join/team_list/uid/22?share_text=3&share_pic=12');
console.log(t[1]);