Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How do I remove whitespace at the beginning or end of my string?

by Roy Johnson (Monsignor)
on Jan 27, 2004 at 18:07 UTC ( [id://324502]=note: print w/replies, xml ) Need Help??

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%       --
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://324502]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-04-23 07:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found