By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,461 Members | 1,002 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,461 IT Pros & Developers. It's quick & easy.

FAQ Topic - How do I trim whitespace - trim/trimRight/trimLeft (2008-08-28)

P: n/a
FAQ Topic - How do I trim whitespace -

Using Regular Expressions (JavaScript 1.2/JScript 3+) :

String.prototype.trimLeft =
return this.replace(/^\s+/,'');
String.prototype.trimRight =
return this.replace(/\s+$/,'');
String.prototype.trim =
return this.replace(/^\s+|\s+$/g,'');
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at
The FAQ workers are a group of volunteers. The sendings of these
daily posts are proficiently hosted by

Aug 27 '08 #1
Share this Question
Share on Google+
1 Reply

P: n/a
In comp.lang.javascript message <48***********************@news.sunsite.
dk>, Wed, 27 Aug 2008 23:00:02, FAQ server <ja********>
Note : while that page is elderly, it provides an excellent source for
the text that it contains, because (unlike so much else) it does not
override the font settings of the browser.

(c) John Stockton, nr London, UK. ? Turnpike v6.05 MIME.
Web <URL: FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "" (SonOfRFC1036)
Aug 28 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.