use strict;
my $str = '<b> GALADRIEL (V.O.)
</b> (Elvish: subtitled)
"I amar prestar sen: han mathon ne nen,
han mathon ne chae...a han noston ned
wilith."
(English:)
The world is changed: I feel it in the
water, I feel it in the earth, I smell it
in the air...Much that once was is lost,
for none now live who remember it.
<b>SUPER: THE LORD OF THE RINGS
</b>
<b>EXT. PROLOGUE -- DAY
</b>
IMAGE: FLICKERING FIRELIGHT. The NOLDORIN FORGE in EREGION.
MOLTEN GOLD POURS from the lip of an IRON LADLE.
<b> GALADRIEL (V.O.)
</b> It began with the forging of the Great
Rings.
IMAGE: THREE RINGS, each set with a single GEM, are received
by the HIGH ELVES-GALADRIEL, GIL-GALAD and CIRDAN.
<b> GALADRIEL (V.O.) (CONT\'D)
</b> Three were given to the Elves, immortal,
wisest...fairest of all beings.
IMAGE: SEVEN RINGS held aloft in triumph by the DWARF LORDS.
<b> GALADRIEL (V.O.) (CONT\'D)
</b> Seven to the Dwarf Lords, great miners
and craftsmen of the mountain halls.
IMAGE: NINE RINGS clutched tightly by the KINGS OF MEN...as
if holding-close a precious secret.
<b> GALADRIEL (V.O.) (CONT\'D)
</b> And Nine...nine rings were gifted to the
race of Men who, above all else, desire
power.
<b> (MORE)
</b>';
my $regex = qr/<b>(.*?)<\/b>/msp;
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