![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
There is an interseting examination of varions trim functions here: URL: http://blog.stevenlevithan.com/archi...rim-javascript The best all-round function seems to be trim3 when strings have lots of leading and trailing whitespace, which is when other functions slow down and speed is of most importance. |
#3
| |||
| |||
|
|
function myTrim1 (str) { var str = str.replace(/^\s\s*/, ''); str = str.replace(/\s\s*$/, ''); }; function trim1 (str) { var str = str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }; His trim1 taking nearly TWICE the time myTrim1 takes in IE7 and FF2 |
![]() |
| Thread Tools | |
| Display Modes | |
| |