const regex = /(?:^\d+.*\R)?(?:4-Diepi|5-Mts|.*\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\d{4}\b.*)$(*SKIP)(*F)|^\d+.*\R(\d+.*)$/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?:^\\d+.*\\R)?(?:4-Diepi|5-Mts|.*\\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\d{4}\\b.*)$(*SKIP)(*F)|^\\d+.*\\R(\\d+.*)$', 'gm')
const str = `Peie
71,176,953
T-re
71,173,557
5-Mts
41,653,495
45678
Sia
36,136,829
36,100,829
4-Diepi
120,829
uteCra
36,100
Oct2018`;
// 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