Benchmark: timing 100000 iterations of 1, 2, 3... 1: 22 wallclock secs @ 4553.73/s 2: 13 wallclock secs @ 7575.76/s 3: 15 wallclock secs @ 6765.90/s #### use strict; use Benchmark; my $str=q(this is some text
a block quote
some more text maybe some other tags
another block
we end here); sub method1 { my $s=shift; $s=~s@
((?:[^<]|<\/?s)*)<\/div>@
$1
@g; } sub method2 { my $s=shift; $s=~s@
((?:[^<]*|<\/?s)*)<\/div>@
$1
@g; } sub method3 { my $s=shift; $s=~s@
((?:.|\n)*?)<\/div>@
$1
@g; } timethese(100000, {'1' => sub { method1($str) }, '2' => sub { method2($str) }, '3' => sub { method3($str) }});