Information
Wednesday, February 3, 2010
Trim Function in Javascript
function
trim
(str)
{
if(!str || typeof str != '
string
')
return null;
return
str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment