开发者

Regex to get return the first two ints

Given a string like: #/projects/58/tasks/140

I want to be able to extract 58 & 140.

I have the following:

parseInt(hash.match(/\d+/开发者_JAVA百科)[0]);

This gets 58, but I can't get 140 with:

parseInt(hash.match(/\d+/)[1])

y? thanks


Use "g" modifier

 hash.match(/\d+/g)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜