const regex = new RegExp('^(\\d{2})\\s(\\d.\\d)\\s(\\w+(?:-+\\w+)*(?:--\\w)?-?)\\s((?:\\d+,)?\\d+.\\d+)\\s((?:\\d+,)?\\d+.\\d+)$', 'gm')
const str = `69 1.0 PKS-EKC-FlYCTRK--Y 2,110.28 2,110.28
70 2.0 ACS-PMM 31.75 63.50
72 1.0 PKS-TR1-CRD 308.14 308.14
73 1.0 QTC-01HZZ-RBER058- 1,725.57 1,725.57
74 1.0 MGS-05B-4TC-120--8 1,222.84 1,222.84
75 1.0 ACS-VGY 98.60 98.60
76 2.0 ACS-VGG 27.27 54.53
77 2.0 ACS-VGQ 110.93 221.86
78 2.0 ECS-ENM--845 1,294.18 2,588.36
80 1.0 FREIGHT 4,188.00 4,188.00
`;
// 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