[Javascript] trim function (regex)
Shawn Milo
milo at linuxmail.org
Wed May 5 14:50:47 CDT 2004
----- Original Message -----
From: "jsWalter" <jsWalter at torres.ws>
Date: Wed, 5 May 2004 14:04:43 -0500
To: "'[JavaScript List]'" <javascript at LaTech.edu>
Subject: RE: [Javascript] trim function (regex)
> OK, since you offered...
>
> This adds it as a new method off the String Object.
>
> Walter
>
<snip>
> return this.replace(/^\s+|\s+$/g, "");
<snip>
I like that regex of yours. It's almost the exact opposite of mine,
but does the same job. I still prefer the one I used, because it
seems clearer to me when I read it, but yours is probably more elegant.
Shawn
More information about the Javascript
mailing list