可能重复:
如何在 javascript 中修剪字符串?
我只需要从通用字符串中删除最后一个和第一个空格。
例子:
var str = " hello world "; // become "hello world"
var str = "ehi, do you come from ? "; // become "ehi, do you come from ?"
var str = "I am from Cina"; // remain "I am from Cina"
我怎样才能做到这一点 ?