网上关于字符串去除首尾空格的方法有很多,大多比较复杂难用,下面给出一个效率简洁的版本:

 var str=' china   ';
 str= str.replace(/^\s+|\s+$/g, '');

结果str='china';

 

相关文章:

  • 2021-07-10
  • 2022-12-23
  • 2021-12-01
  • 2021-11-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-07
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案