var myString = 'Sent from your Zoom trial account - Your verification code is: 621226';
var regEx = /(\d+)$/g;
var result = regEx.exec(myString);
然而结果= [621226,621226]而不仅仅是[621226]
答案 0 :(得分:0)
将.match()
与regEx
一起用作myString
链接的参数。
var myString = 'Sent from your Zoom trial account - Your verification code is: 621226';
var regEx = /(\d+)$/g;
var result = myString.match(regEx);
console.log(result);