Is there a func or a onliner for removing blanks from both ends?
I'm using these:
$username =~ s/^\s+//;
$username =~ s/\s+$//;
There got to be one out there!
thanks,
-rkl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
On Monday, September 29, 2003, at 07:04 PM, [EMAIL PROTECTED] wrote:
Is there a func or a onliner for removing blanks from both ends?
I'm using these:
$username =~ s/^\s+//;
$username =~ s/\s+$//;
We could combine those:
$username =~ s/^\s*(.*?)\s*$/$1/;
Hope that helps.
James
--
To
foox200);
}
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 8:04 PM
To: [EMAIL PROTECTED]
Subject: remove blanks
Is there a func or a onliner for removing blanks from both ends?
I'm using these:
$username =~ s/^\s+//;
$username =~ s
[EMAIL PROTECTED] wrote:
Is there a func or a onliner for removing blanks from both ends?
I'm using these:
$username =~ s/^\s+//;
$username =~ s/\s+$//;
There got to be one out there!
Doing it in two steps is the way to go. Don't try to make one regex out of
it.
I usually write it this
this looks convenience
thanks,
-rkl
[EMAIL PROTECTED] wrote:
Is there a func or a onliner for removing blanks from both ends?
I'm using these:
$username =~ s/^\s+//;
$username =~ s/\s+$//;
There got to be one out there!
Doing it in two steps is the way to go. Don't try to make one
:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 8:04 PM
To: [EMAIL PROTECTED]
Subject: remove blanks
Is there a func or a onliner for removing blanks from both ends?
I'm using these:
$username =~ s/^\s+//;
$username =~ s/\s+$//;
There got to be one out there!
thanks,
-rkl
: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Monday, September 29, 2003 8:04 PM
To: [EMAIL PROTECTED]
Subject: remove blanks
Is there a func or a onliner for removing blanks from both ends?
I'm using these:
$username =~ s/^\s+//;
$username =~ s/\s+$//;
There got to be one out
On Sep 29, Hanson, Rob said:
I ran some benchmarks.
The two-liner outperformed the one-liners by a 10 to 1 ratio. Code and
results below.
Benchmark: timing 10 iterations of OneLine, OneLine2, TwoLines...
OneLine: 41 wallclock secs (39.30 usr + 0.00 sys = 39.30 CPU) @ 2544.79/s