仅在几个时匹配最后一次出现

use*_*355 3 javascript regex match

我有一个字符串: "http://www.website.com/20170401_63582484.htm"

然后我尝试匹配63582484: "http://www.website.com/20170401_63582484.htm".match(/\d{8}/)

但后来我得到了答案20170401.如何更改match为仅匹配8位数的最后一次出现?

fal*_*tru 5

使用全局flag(g),并获取最后一个:

var matches = "http://www.website.com/20170401_63582484.htm".match(/\d{8}/g);
matches[matches.length - 1]  // => "63582484"
Run Code Online (Sandbox Code Playgroud)