为String扩展trim方法

String.prototype.trim = function(){

//return this.replace(/(^\s*)|(\s*$)/g, "");
//去 与' '空格
return this.replace(/(^\s*)|(\s*$)/g, "").replace(/(^( )*)|(( )*$)/g, "");
}

使用JQuery提供的trim()方法

$.trim(str);

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
猜你喜欢
  • 2021-12-21
  • 2022-12-23
  • 2022-02-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案