String.prototype.Trim = function()
{
     return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function()
{
     return this.replace(/(^\s*)/g, "");
}
String.prototype.Rtrim = function()
{
     return this.replace(/(\s*$)/g, "");
}
使用方式

var s = "     leading and trailing spaces     ";

s = s.Trim();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2021-12-07
  • 2021-08-19
  • 2021-11-01
  • 2021-11-01
  • 2022-12-23
  • 2021-12-11
  • 2021-07-03
相关资源
相似解决方案