javascript - regular matching characters
某草草
某草草 2017-06-12 09:30:09
0
5
792

url = ‘http://1dwen.cn/index.php/joi...’
How to use regular expression to match the value 22 after uid? Can any expert help me?

某草草
某草草

reply all(5)
代言
'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]
扔个三星炸死你

Can I understand that you only need to match the last number

\d+(?=[^\d]*$)
洪涛
/https?:\/\/(?:[^\/]+\/)+(\d+)/
大家讲道理
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);

给我你的怀抱

For js or java, you can use methods such as indexOf and subString

 var index = 'asdf'.indexOf('s') ;//  ---> 1
 'asdf'.substring(index); //....

If you are using regular expressions (js version), you can use regular expression grouping:

t = /uid\/(.*)\?/.exec('http://1dwen.cn/index.php/join/team_list/uid/22?share_text=3&share_pic=12');
console.log(t[1]);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template