<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <meta charset="utf-8" /> <script type="text/javascript"> //var msg = '罗分明18305709196lqwvje15217187240周丹17052760187'; //var resg = /[0-9]+/g; //var ruesult = resg.exec(msg); //while (ruesult) { // alert(ruesult); // var ruesult = resg.exec(msg); //} //以下方法 跟上面功能一样 var msg = '罗分明18305709196lqwvje15217187240周丹17052760187'; var resg = /[0-9]+/g; var datas = msg.match(resg); for (var i = 0; i < datas.length; i++) { alert(datas[i]); } </script> </head> <body> </body> </html>