const regex = new RegExp('^[\\w\\s./-]*(?:\\s\\d+){4}(?:\\s\\$\\d+\\.\\d+){2}$', 'gm')
const str = `Amount
2144-PL
1XL 2XL 3XL
2144-
PL Navy Blue 2 2 2 6 \$11.50 \$69.00
ETK-2097K-PL PLUS-TOP - BACK BUTTON TUNICS 95% RAYON 5% SPANDEX MADE IN USA
1XL 2XL 3XL
Black 2 2 2 6 \$12.00 \$72.00
Teal 2 2 2 6 \$12.00 \$72.00
ETK-2197-SW-
1XL 2XL 3XL
PL ETK-
2197- H.Grey/Burgu… 2 2 2 6 \$14.00 \$84.00
Off-White/Black 1 1 1 3 \$14.00 \$42.00
ETK-2143 Tops - 95% RAYON 5% SPANDEX MADE IN USA
S M L
Heather Grey 2 2 2 6 \$10.50 \$63.00
Royal Blue 2 2 2 6 \$10.50 \$63.00
Ruby Red 2 2 2 6 \$10.50 \$63.00
ETK2186-GD- Tops-Stripe Solid-95% Rayon 5% Spandex Made in USA
PL
1XL 2XL 3XL
Burgundy/Bur… 2 2 2 6 \$11.00 \$66.00
Ivory/Black 2 2 2 6 \$11.00 \$66.00
2139 - WP-PL PLUS TOP -95% RAYON 5% SPANDEX MADE IN USA
1XL 2XL 3XL
As Shown 2 2 2 6 \$9.50 \$57.00
ETK-2228
S M L
ETK-
2228 Off-White/Black 2 2 2 6 \$9.50 \$57.00
ETK-2149-PL
1XL 2XL 3XL
ETK-
2149- Taupe 2 2 2 6 \$11.50 \$69.00
BACK
ORDERED
White 2 2 2 6 \$11.50 \$69.00
Sub`;
// 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