Help for this page

Select Code to Download


  1. or download this
    use Benchmark 'cmpthese';
    use Regexp::Common 'whitespace';
    ...
      's-capture2'    => sub { $_=$f; s/^\s*(\S+(?:\s+\S+)?)?\s*$/$1/; },
      'm-capture'     => sub { $_=$f; ($_) = /(\S+(?:\s+\S+)?)/;    },
    });
    
  2. or download this
                     Rate Regexp-Common s-capture one-s/// s-capture2 m-ca
    +pture two-s///
    Regexp-Common   659/s            --      -91%     -93%       -95%     
    + -96%     -97%
    ...
    s-capture2    12699/s         1827%       81%      43%         --     
    + -26%     -51%
    m-capture     17179/s         2507%      145%      94%        35%     
    +   --     -34%
    two-s///      25941/s         3837%      270%     193%       104%     
    +  51%       --