JAVASCRIPT : Tips

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
krishnan
Forum Newbie
Posts: 2
Joined: Thu Mar 11, 2010 7:42 am

JAVASCRIPT : Tips

Post by krishnan »

Remove space :

string.replace(/^\s*|\s*$/,"");
User avatar
tr0gd0rr
Forum Contributor
Posts: 305
Joined: Thu May 11, 2006 8:58 pm
Location: Utah, USA

Re: JAVASCRIPT : Tips

Post 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`.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: JAVASCRIPT : Tips

Post by pickle »

This is better suited for the Javascript forum.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply