Subj : Re: truncsp() for beginnings of strings?
To   : Tracker1
From : Deuce
Date : Wed Nov 18 2009 09:29 am

 Re: Re: truncsp() for beginnings of strings?
 By: Tracker1 to art on Tue Nov 17 2009 10:19 pm

>    return this.replace(/^[\s\r\n]+/g, '');

\s includes \r and \n.  The g flag is useless since + is greedy by default and
the match is anchored to the start of the string (unless you want multilines,
which you don't).

So just replace(/^\s+/, '');

As for the whole string trim function...

>    return this.replace(/^[\s\r\n]+|[\s\r\n]+$/g, '');

replace(/^\s*(.*?)\s*$/, '$1');

Is a lot better (a single replace, no OR, etc).

---
Synchronet - Jump on the Web 0.2 bandwagon!

---
� Synchronet � My Brand-New BBS (All the cool SysOps run STOCK!)