Puoi usare una funzione trim.

http://forum.html.it/forum/showthrea...highlight=trim