2007/12/19 03:13

1: 过滤首尾空格trim、2:过滤左边空格ltrim    3:过滤右边空格  

一:用正则方法写成三个函数.

<script type="text/javascript">
function trim(str){ //删除左右两端的空格
return str.replace(/(^\s*)|(\s*$)/g, "");
}
function ltrim(str){ //删除左边的空格
return str.replace(/(^\s*)/g,"");
}
function rtrim(str){ //删除右边的空格
return str.replace(/(\s*$)/g,"");
}
</script>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-18
  • 2021-05-19
  • 2021-11-12
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-11
  • 2022-12-23
  • 2019-12-09
  • 2022-02-25
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案