Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / August 2008



Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
FAQ server - 28 Aug 2008 00:00 GMT
-----------------------------------------------------------------------
FAQ Topic - How do I trim whitespace -
trim/trimRight/trimLeft
-----------------------------------------------------------------------

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

String.prototype.trimLeft =
     function()
      {
       return this.replace(/^\s+/,'');
      }
String.prototype.trimRight =
     function()
      {
       return this.replace(/\s+$/,'');
      }
String.prototype.trim =
     function()
      {
       return this.replace(/^\s+|\s+$/g,'');
      }

http://docs.sun.com/source/816-6408-10/regexp.htm

http://msdn2.microsoft.com/en-us/library/6wzad2b2.aspx

http://en.wikipedia.org/wiki/Regular_expression

http://www.informatics.sussex.ac.uk/courses/it/tutorials/nsJavaScriptRef/contents.htm

http://www.merlyn.demon.co.uk/js-valid.htm

Signature

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 http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers.  The sendings of these
daily posts are proficiently hosted by http://www.pair.com.

Dr J R Stockton - 28 Aug 2008 21:35 GMT
In comp.lang.javascript message <48b5dc7c$0$90275$14726298@news.sunsite.
dk>, Wed, 27 Aug 2008 23:00:02, FAQ server <javascript@dotinternet.be>
posted:

>http://www.informatics.sussex.ac.uk/courses/it/tutorials/nsJavaScriptRef/contents.htm

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.

Signature

(c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk  Turnpike v6.05  MIME.
Web  <URL:http://www.merlyn.demon.co.uk/> - 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)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.