Connecting Tech Pros Worldwide Help | Site Map

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

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 27th, 2008, 11:05 PM
FAQ server
Guest
 
Posts: n/a
Default FAQ Topic - How do I trim whitespace - trim/trimRight/trimLeft (2008-08-28)

-----------------------------------------------------------------------
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/...f/contents.htm

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


--
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.


  #2  
Old August 28th, 2008, 10:45 PM
Dr J R Stockton
Guest
 
Posts: n/a
Default Re: FAQ Topic - How do I trim whitespace - trim/trimRight/trimLeft (2008-08-28)

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: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. ?@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)
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.