JavaScript 去前后全脚半脚空格的正则

  function trim(str)

  {

  return str.replace(/(^\s*)|(\s*$)/g, "");

  }