- or download this
use strict;
my $input='
...
my @arr=$input=~m#<[^<>]+(?:<a>.+?</a>[^<>]*)?>#g;
print join "\n",@arr;
- or download this
qr {<(?:[^<>]+|<a>|</a>)*>}
- or download this
qr {<(?:[^<>]+|<a>|</a>)*[^>]*>}
- or download this
my $re;
$re=qr{(?:[^<>]+|<a>(??{$re})?</a>)*};
my @arr=$input=~m#<$re>#g;