const regex = /Count\.AutoSlam\.OAK4\.(?P<autoslam>\d+) \[Weekly Avg: (?P<weekly_avrg>\d\.\d{2})\]/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('Count\\.AutoSlam\\.OAK4\\.(?P<autoslam>\\d+) \\[Weekly Avg: (?P<weekly_avrg>\\d\\.\\d{2})\\]', 'gm')
const str = `Label,Min,Avg,Max,Nov 23,11:00,Nov 23,12:00,Nov 23,13:00,Nov 23,14:00,Nov 23,15:00,Nov 23,16:00,Nov 23,17:00,Nov 23,18:00,Nov 23,19:00,Nov 23,20:00,Nov 23,21:00,Nov 23,22:00,Nov 23,23:00,Nov 24,00:00,Nov 24,01:00,Nov 24,02:00,Nov 24,03:00,Nov 24,04:00,Nov 24,05:00,Nov 24,06:00,Nov 24,07:00,Nov 24,08:00,Nov 24,09:00,Nov 24,10:00,Nov 24,11:00,Nov 24,12:00,Nov 24,13:00,Nov 24,14:00,Nov 24,15:00,Nov 24,16:00,Nov 24,17:00,Nov 24,18:00,Nov 24,19:00,Nov 24,20:00,Nov 24,21:00,Nov 24,22:00,Nov 24,23:00,Nov 25,00:00,Nov 25,01:00,Nov 25,02:00,Nov 25,03:00,Nov 25,04:00,Nov 25,05:00,Nov 25,06:00,Nov 25,07:00,Nov 25,08:00,Nov 25,09:00,2 - Count.AutoSlam.OAK4.3. [Weekly Avg: 0.56] 0.0 0.56 2.38 0.0 2.27 0.0 0.0 0.16 0.30 0.25 1.07 1.79 2.38 0.0 0.98 0.0 0.0 0.0 0.0 0.41 0.47 0.60,7 - Count.AutoSlam.OAK4.18 [Weekly Avg: 0.29] 0.0 0.29 2.34 0.0 0.0 0.0 0.0 0.0 0.0 2.34 0.0,5 - Count.AutoSlam.OAK4.13 [Weekly Avg: 0.34] 0.0 0.34 2.08 0.83 0.30 0.32 0.19 0.26 0.47 0.36 0.0 0.22 0.11 0.36 0.65 0.41 0.52 0.85 0.88 1.28 0.0 0.0 1.19 0.0 0.0 0.0 0.0 0.0 2.08 0.0 0.0 0.45 0.79 0.32 0.0 0.0 0.0 0.0 0.0 0.35 0.0 0.15,1 - Count.AutoSlam.OAK4.6. [Weekly Avg: 0.59] 0.0 0.59 1.79 0.0 0.34 0.11 0.38 0.24 0.19 0.15 0.42 0.69 0.56 0.26 1.26 0.71 1.79 1.51 0.82 1.10 1.40 0.57 0.0 0.85 0.34 0.0 0.15 0.29 0.86 0.35 0.39 0.78 1.09 1.35 0.68 0.70 1.02 1.66 1.15 0.31 0.0 0.0 0.0 0.077 0.13,11 - Count.AutoSlam.OAK4.19 [Weekly Avg: 0.23]`;
// 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