c:\@Work\Perl>perl -wMstrict -le "use Benchmark qw/cmpthese/; ;; my $string = '1:13:1:6:5854:0x00E37F06:0x00D1314C'; my $result; ;; sub _split { $result = join ':', (split /:/, $string)[0 .. 2]; } ;; sub _split_LIMIT { $result = join ':', (split /:/, $string, 4)[0 .. 2]; } ;; sub _regex { ($result) = $string =~ m{ \A \d+ : \d+ : \d+ }xmsg; } ;; cmpthese(-5, { _split => \&_split, _split_LIMIT => \&_split_LIMIT, _regex => \&_regex, }); " Rate _split _split_LIMIT _regex _split 261407/s -- -39% -54% _split_LIMIT 425387/s 63% -- -24% _regex 562521/s 115% 32% --