Page 1 of 1

JAVASCRIPT : Tips

Posted: Thu Mar 11, 2010 10:17 am
by krishnan
Remove space :

string.replace(/^\s*|\s*$/,"");

Re: JAVASCRIPT : Tips

Posted: Thu Mar 11, 2010 2:22 pm
by tr0gd0rr
Also note that String#trim has been added to the JavaScript spec. It is faster and more reliable. For example, some browsers do not include weird Unicode characters that display as a space as part of `\s`.

Re: JAVASCRIPT : Tips

Posted: Fri Mar 12, 2010 10:34 am
by pickle
This is better suited for the Javascript forum.