use strict;
my $str = '<table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
<caption>Турнірна таблиця групи «J»:</caption>
<tbody>
<tr>
<td>№</td>
<td>Команда</td>
<td>І</td>
<td>В</td>
<td>Н</td>
<td>П</td>
<td>З:П</td>
<td>О</td>
</tr>
<tr>
<td>1.</td>
<td>«Естерсунд» (Швеція)</td>
<td>3</td>
<td>2</td>
<td>1</td>
<td>0</td>
<td>5:2</td>
<td>7</td>
</tr>
<tr>
<td>2.</td>
<td><strong>«ЗОРЯ» (Україна)</strong></td>
<td>3</td>
<td>2</td>
<td>0</td>
<td>1</td>
<td>3:3</td>
<td>6</td>
</tr>
<tr>
<td>3.</td>
<td>«Атлетік» (Іспанія)</td>
<td>3</td>
<td>0</td>
<td>2</td>
<td>1</td>
<td>2:3</td>
<td>2</td>
</tr>
<tr>
<td>4.</td>
<td>«Герта» (Німеччина)</td>
<td>3</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>1:3</td>
<td>1</td>
</tr>
</tbody>
</table>';
my $regex = qr/<caption>((?:.)*?)<\/caption>/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