const regex = new RegExp('(?:\\$[\\d+,]{,100})', 'gm')
const str = `Ваша ассоциация наняла рабочего Стэнфорд Флеминг за \$208,000,000. Основным соперником была ассоциация Путь со ставкой \$195,440,000.
Следующие игроки приняли участие в аукционе:
DikoBrazzers: \$28,450,000
рус73: \$27,880,000
TANK1515: \$20,110,000
Крысолов: \$20,000,000
Валентинович 55: \$19,860,000
Slepoy 16ru: \$15,000,000
Виктор 74: \$13,680,000
корефанец: \$10,850,000
Папа Djo: \$10,210,000
Кадима: \$10,020,000
Aleks Mechanic: \$9,410,000
пожик47: \$9,300,000
super_skif: \$7,590,000
Лoки: \$5,640,000`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions