我正在尝试从javascript字符串中获取最大的数字(1,000,000)。
但是现在从开发者工具中获得的输出结果是:
var teststr = "jUDGES/COACHES: \
jAcKsoN PALMeR 1 ATIF NAZlR l jAMES BLAHA l DAVEWl1gGENT \
PITCH PROTOTYPE PRESENT \
YOUR PRODUCT \
ul;"" \
1 \
bra GWDEAWAYS \
GRAND PéizE \
1,000,000 DOG COIN \
€ Prize PUbNUlS Prize \
750,000 DOGECOIN 750,000 DOGECOIN \
AFTER PARTY WITH SPECIAL GUEST Dj \
jACKSON PALnkjnjnkjMER \
JULY 26TH 3PM -]ULY 27TH 11PM";
function parseReg(string) {
//var re = "(\d+)((.?)(\d+))+([\.\d\d]?)";
return /(\d+)((.?)(\d+))+([\.\d\d]?)/g.exec(string);
}
console.log(parseReg(teststr));
但是现在从开发者工具中获得的输出结果是:
["1,000,000", "1", ",000", ",", "000", "", index: 187, input: "jUDGES/COACHES: jAcKsoN PALMeR 1 ATIF NAZlR l … PALnkjnjnkjMER JULY 26TH 3PM -]ULY 27TH 11PM"]
我刚开始学习JavaScript,不太确定如何做到这一点。我相信我已经正确使用了正则表达式,但不确定为什么字母被捕获了。
index:
在哪里包含了? - Liondancer