const regex = new RegExp('^DATE:.*((?:\\n(?!AREA:).*)+)', 'gm')
const str = `AREA: OMBEYI MARKET, ST. RITA RAMULA
DATE: Thursday 25.03.2021, TIME: 9.00 A.M. = 5.00 P.M.
Ombeyi Mk, Kiliti Mkt, Masogo Mkt, Miwani, Kasongo, Onyango Midika, St. Rita Ramula, Onyalo
Biro, Yawo Pri, Obino, Rutek, Keyo Pri & adjacent customers.
AREA: NYAMACHE FACTORY
DATE: Thursday 25.03.2021, TIME: 830 A.M. - 3.00 P.M.
Nyamache Fact, Suguta, Gionseri, Igare, Kionduso, Nyationgongo, Enchoro, Kebuko, Emenwa, Maji
Mazuri, Borangi & adjacent customers.
AREA: SUNEKA MARKET, RIANA MARKET
DATE: Thursday 25.03.2021, TIME: 8.00 A.M. - 3.00 P.M.
Suneka Mk, Riana Mk, Kiabusura, Gesonso, Chisaro, Sugunana, Nyamira Ndogo & adjacent
customers.
AREA: ITIATI, GITUNDUTI
DATE: Thursday 25.03.2021, TIME: 9.00 A.M. = 2.00 P.M.
General China, Gachuiro, Gathuini Pri, Itiati Campus, Kianjugum, Gikore, Kihuri TBC, Gitunduti &
adjacent customers.`;
// 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