F
FAQ server
-----------------------------------------------------------------------
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://msdn.microsoft.com/library/d...html/2380d458-3366-402b-996c-9363906a7353.asp
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
--
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.
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://msdn.microsoft.com/library/d...html/2380d458-3366-402b-996c-9363906a7353.asp
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
--
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.