开发者

searching number in body using jquery

i am trying to search all numbers (of digit开发者_JAVA技巧s 8) in body using jQuery, its only returning first no. in body?

var myRe = /[0-9]{8}/;  
var myArray = myRe.exec($('body').html());  
alert(myArray);


Add the g or 'global' flag to the regular expression. Now instead of using exec() which only returns the first match, call match() on the string itself, which returns an array of all results:

var myRe = /[0-9]{8}/g;
var myArray = $('body').html().match(myRe);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜