use strict;
my $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.';
my $regex = qr/^DATE:.*((?:\n(?!AREA:).*)+)/mp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
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 Perl, please visit: http://perldoc.perl.org/perlre.html