String.prototype.trim= function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); };
来源:互联网 发布:手机酷狗显示网络错误 编辑:程序博客网 时间:2024/06/05 09:47
String.prototype.trim= function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
return this.replace(/(^\s*)|(\s*$)/g, "");
}
以字符串开头或以字符串结尾
涉及规则:
\
将下一个字符标记符、或一个向后引用、或一个八进制转义符。例如,“\\n”匹配\n。“\n”匹配换行符。序列“\\”匹配“\”而“\(”则匹配“(”。即相当于多种编程语言中都有的“转义字符”的概念。
^
匹配输入字符串的开始位置。如果设置了RegExp对象的Multiline属性,^也匹配“\n”或“\r”之后的位置。
$
匹配输入字符串的结束位置。如果设置了RegExp对象的Multiline属性,$也匹配“\n”或“\r”之前的位置。
*
匹配前面的子表达式任意次。例如,zo*能匹配“z”,“zo”以及“zoo”。*等价于{0,}。
.点
匹配除“\r\n”之外的任何单个字符。要匹配包括“\r\n”在内的任何字符,请使用像“[\s\S]”的模式。
(pattern)
匹配pattern并获取这一匹配。所获取的匹配可以从产生的Matches集合得到,在VBScript中使用SubMatches集合,在JScript中则使用$0…$9属性。要匹配圆括号字符,请使用“\(”或“\)”。
0 0
- String.prototype.trim= function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); };
- JS中 String.prototype.Trim = function()
- String.prototype.trim=function是什么意思?
- String.replace(/\s/g,'')中的‘/\s/g’表示什么意思?
- String.prototype.trim=function是做什么用的?
- replace(/\s/g,"")中的/g是什么意思?
- js constructor function V.S static method V.S prototype
- String.prototype.trim
- js String.prototype.trim()
- c++ trim function string
- return this.each(function(){})
- replace(//s/g,"")中的/g是什么意思? 及replace函数的用法
- String s; String s = null; String s = ""; .intern()
- String s = null ; String s = "" ; String s ;
- /(^\s*)|(\s*$)/g
- 用正则表达式将前后空格用空字符串替代:replace(/(^\s*)|(\s*$)/g, "")
- 用正则表达式将前后空格用空字符串替代:replace(/(^\s*)|(\s*$)/g, "")
- 【正则表达式】将前后空格用空字符串替代: str.replace(/(^\s*)|(\s*$)/g, "")
- C#字典Dictionary排序(顺序、倒序)
- gearman到底是什么-gearman官网片段翻译
- javascript数组操作
- 清除缓存相关明细
- Qt基本语法
- String.prototype.trim= function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); };
- ResultSet
- 用sql语句实现年龄分段统计
- easyui验证扩展
- 在CordovaActivity中添加原生View组件
- powershell 汉字转拼音
- libevent代码阅读(5)——“hello-world.c”之 event_base对象的创建
- linux下c/c++实例之六时间测试和定时器
- Qt 备忘录