use strict;
my $str = '<p>
<span style="visibility:hidden" id="Synonyme">
<span id="Anker:Synonyme"></span>
</span>
</p>
<div style="margin-bottom:-0.5em; font-weight:bold;" title="bedeutungsgleich gebrauchte Wörter">Synonyme:</div>
<dl>
<dd>[1] <a href="/w/index.php?title=Blutsverwandte&action=edit&redlink=1" class="new" title="Blutsverwandte (Seite nicht vorhanden)">Blutsverwandte</a>,
<a href="/wiki/Sippe" title="Sippe">Sippe</a>
<dl>
<dd>[1a] <a href="/wiki/Kernfamilie" title="Kernfamilie">Kernfamilie</a></dd>
<dd>[1b] <i>abwertend, salopp:</i> <a href="/wiki/Mischpoke" title="Mischpoke">Mischpoke</a></dd>
</dl>
</dd>
<dd>[2] <a href="/wiki/Abart" title="Abart">Abart</a>,
<a href="/wiki/Art" title="Art">Art</a>,
<a href="/wiki/Bereich" title="Bereich">Bereich</a>,
<a href="/wiki/Departement" title="Departement">Departement</a>,
<a href="/wiki/Dialekt" title="Dialekt">Dialekt</a>,
<a href="/wiki/Fach" title="Fach">Fach</a>,
<a href="/wiki/Gattung" title="Gattung">Gattung</a>,
<a href="/wiki/Genus" title="Genus">Genus</a>,
<a href="/wiki/Geschlecht" title="Geschlecht">Geschlecht</a>,
<a href="/wiki/Gruppe" title="Gruppe">Gruppe</a>,
<a href="/wiki/Kategorie" title="Kategorie">Kategorie</a>,
<a href="/wiki/Linie" title="Linie">Linie</a>,
<a href="/wiki/Rasse" title="Rasse">Rasse</a>,
<a href="/wiki/Reihe" title="Reihe">Reihe</a>,
<a href="/wiki/Rubrik" title="Rubrik">Rubrik</a>,
<a href="/wiki/Schlag" title="Schlag">Schlag</a>
</dd>
</dl>';
my $regex = qr~<dl>(?:[^<]+|<(?!/?dl\b)|(?R))*+</dl>~isp;
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