use Benchmark qw(cmpthese); fbard@devo1:~/spot_camp_layout$ cat rindex use Benchmark qw(cmpthese); my $x = ("x" x 100_000).""; my $lc_x = lc($x); my $end_html = qr{()}; cmpthese(100_000,{ rindex_substr => sub{ my $str = $x; substr($str,rindex($lc_x,""),0,"yyyy"); }, regex => sub{ my $str = $x; $str =~ s|$end_html$|yyyy$1|i; } }); Rate regex rindex_substr regex 18416/s -- -75% rindex_substr 73529/s 299% --