Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   FAQ Topic - How do I trim whitespace - trim/trimRight/trimLeft (2008-02-29) (http://www.velocityreviews.com/forums/t934899-faq-topic-how-do-i-trim-whitespace-trim-trimright-trimleft-2008-02-29-a.html)

FAQ server 02-29-2008 12:00 AM

FAQ Topic - How do I trim whitespace - trim/trimRight/trimLeft (2008-02-29)
 
-----------------------------------------------------------------------
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.


Dr J R Stockton 02-29-2008 10:22 PM

Re: FAQ Topic - How do I trim whitespace - trim/trimRight/trimLeft (2008-02-29)
 
In comp.lang.javascript message <47c74b07$0$90270$14726298@news.sunsite.
dk>, Fri, 29 Feb 2008 00:00:02, FAQ server <javascript@dotinternet.be>
posted:

>FAQ Topic - How do I trim whitespace -
>trim/trimRight/trimLeft


Section neither states nor shows how to trim whitespace. A fait
proportion of those asking the question will need an example shoeing the
trimming of a string.

--
(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)


All times are GMT. The time now is 10:47 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.