开发者

How to get Match to return an INT and not an array

开发者 https://www.devze.com 2023-02-28 12:11 出处:网络
I have the following: var hashID = location.hash.match(/\\d/); Where location.hash eqs:#/groups/58 I want hashID to equal = 58

I have the following:

    var hashID = location.hash.match(/\d/);

Where location.hash eqs: #/groups/58

I want hashID to equal = 58

Right now it equals an array. How can I get back j开发者_如何转开发ust 58 as an int? THanks


  var hashID = parseInt(location.hash.match(/\d+/)[0])
0

精彩评论

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