去除段首段尾的 和全角的空格的正则
时间:2021-05-01 09:34:49|栏目:|点击: 次
<script language="javascript">
<!--
String.prototype.trim = function(){
return this.replace(/^( |[\s ])+|( |[\s ])+$/g, "" );
}
alert("---"+ " this is a test kwgkwg ".trim() + "---");
/ --></script>
1、去段首段尾的空格(包括半角的空格代码 和全角的空格" ")
2、段中的空格(包括半角的空格代码 和全角的空格" ")给予保留!
<!--
String.prototype.trim = function(){
return this.replace(/^( |[\s ])+|( |[\s ])+$/g, "" );
}
alert("---"+ " this is a test kwgkwg ".trim() + "---");
/ --></script>
1、去段首段尾的空格(包括半角的空格代码 和全角的空格" ")
2、段中的空格(包括半角的空格代码 和全角的空格" ")给予保留!
上一篇:python 正则表达式 re.sub & re.subn
栏 目:
下一篇:docker 容器上编译 go 程序提示找不到文件问题
本文标题:去除段首段尾的 和全角的空格的正则
本文地址:http://www.codeinn.net/misctech/112688.html






