use strict;
my $str = '<strong><a href="/search/company/company/94613582">Anchor sample Ltd</a></strong><br>
BIS: 94613582 <br>
Hometown: MONTREAL <br>
<div class="hori"></div>
<strong><a href="/search/company/company/046251945">Anchor sample Ltd</a></strong><br>
BIS: 046251945 <br>
Hometown: ALABAMA <br>
<div class="hori"></div>
<strong><a href="/search/company/company/041634545">Anchor sample Ltd</a></strong><br>
BIS: 041634545 <br>
Hometown: GEORGIA <br>
<div class="hori"></div>
<strong><a href="/search/company/company/487915646">Anchor sample Ltd</a></strong><br>
BIS: 487915646 <br>
Hometown: FLORIDA <br>
<div class="hori"></div>
<strong><a href="/search/company/company/165875487">Anchor sample Ltd</a></strong><br>
BIS: 165875487 <br>
Hometown: KANSAS <br>';
my $regex = qr/Hometown: ([^<]+)(?=\s*<)/p;
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