String.prototype.trim1=function(){
return this.replace(/(^\s*)|(\s*$)/g,"");
};
写一个function,清除字符串前后的空格(兼容所有的浏览器)
function trim1(str){
return str.replace(/(^\s*)|(\s*$)/g,"");
}
蓝色海岛 ©著作权
文章标签 String.trim() 文章分类 代码人生
String.prototype.trim1=function(){
return this.replace(/(^\s*)|(\s*$)/g,"");
};
写一个function,清除字符串前后的空格(兼容所有的浏览器)
function trim1(str){
return str.replace(/(^\s*)|(\s*$)/g,"");
}
上一篇:vue组件中name属性有啥作用
下一篇:this指向
警告:Internet Explorer 8 或更低版本不支持 trim() 方法。
trim /[trɪm] / 英文意思:整理,修理,修剪,整齐的 trim()的作用:去掉字符串首尾的空格。 执行结果:a: hello world ,falsea:hello world,true trim()的源代码:
String、StringBuilder和StringBufferString隶属于java.lang包下的类,具体方法参见java的ApIpublic static void main(String[] args) { System.out.println(String.class); } 输出结果为:class java.lang.StringString是引
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M