如何将JavaScript去除字符串首尾空格的方法改写成长尾?
- 内容介绍
- 文章标签
- 相关推荐
本文共计337个文字,预计阅读时间需要2分钟。
方法:1、使用substring(Math.max(this.search(/\\s/), 0), this.search(/\\s+$/)+1)语句;2、使用replace(/\\s+/, '').replace(/\\s+$/, '')语句。
操作环境:Windows 7系统、JavaScript 1.8.5版、Dell G3电脑、使用JavaScript进行去除。
方法:1、用“substring(Math.max(this.search(/\S/),0),this.search(/\S\s*$/)+1)”语句;2、用“replace(/^\s+/,'').replace(/\s+$/,'')”语句。
本文共计337个文字,预计阅读时间需要2分钟。
方法:1、使用substring(Math.max(this.search(/\\s/), 0), this.search(/\\s+$/)+1)语句;2、使用replace(/\\s+/, '').replace(/\\s+$/, '')语句。
操作环境:Windows 7系统、JavaScript 1.8.5版、Dell G3电脑、使用JavaScript进行去除。
方法:1、用“substring(Math.max(this.search(/\S/),0),this.search(/\S\s*$/)+1)”语句;2、用“replace(/^\s+/,'').replace(/\s+$/,'')”语句。

