Prototype RegExp对象 学习
RegExp.prototype.match = RegExp.prototype.test;
RegExp.escape = function(str) {
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
};
就一个escape方法,就是把那几个特殊字符转义一下。
还有就是match方法是test方法的别名。
看一个例子:
var str=RegExp.escape("+.[]$://!");
document.writeln(str) //==> "\+\.\[\]\$\:\/\/\!"
相关推荐
-
Prototype RegExp对象 学习
复制代码 代码如下: RegExp.prototype.match = RegExp.prototype.test; RegExp.escape = function(str) { return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); }; 就一个escape方法,就是把那几个特殊字符转义一下. 还有就是match方法是test方法的别名. 看一个例子: var str=RegExp.escape("+.[]$://!
-
Prototype Enumerable对象 学习第1/2页
Enumerable provides a large set of useful methods for enumerations, that is, objects that act as collections of values. It is a cornerstone of Prototype. Enumerable is what we like to call a module: a consistent set of methods intended not for indepe
-
Prototype Selector对象学习
复制代码 代码如下: function $$() { return Selector.findChildElements(document, $A(arguments)); } 这个类可以分成三个部分:第一个部分就是根据不同的浏览器,判断使用什么DOM操作方法.其中操作IE就是用普通的getElementBy* 系列方法:FF是document.evaluate:Opera和Safari是selectorsAPI.第二部分是对外提供的基本函数,像findElements,match等,Eleme
-
Prototype String对象 学习
复制代码 代码如下: //String对象的静态方法 Object.extend(String, { interpret: function(value) { return value == null ? '' : String(value); }, specialChar: { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '\\': '\\\\' } }); Object.extend(String.prot
-
Prototype ObjectRange对象学习
Ranges represent an interval of values. The value type just needs to be "compatible," that is, to implement a succ method letting us step from one value to the next (its successor). Prototype provides such a method for Number and String, but you
-
Prototype Class对象学习
复制代码 代码如下: /* Based on Alex Arnell's inheritance implementation. */ var Class = (function() { //临时存储parent的prototype function subclass() {}; //创建类的方法 function create() { var parent = null, properties = $A(arguments); //检查新建一个类时,是否指定了一个父对象 //如
-
Prototype Object对象 学习
Object is used by Prototype as a namespace; that is, it just keeps a few new methods together, which are intended for namespaced access (i.e. starting with "Object."). 上面说的namespace个人理解就相当于C#中的静态类,提供工具函数的意思,和C#中的namespace应该不是一个概念.因为C#中的命名空间后面不会直
-
Prototype Hash对象 学习
复制代码 代码如下: //Hash对象的工具函数 function $H(object) { return new Hash(object); }; var Hash = Class.create(Enumerable, (function() { //初始化,创建一个新的Hash对象 function initialize(object) { this._object = Object.isHash(object) ? object.toObject() : Object.clone(obje
-
Prototype Array对象 学习
复制代码 代码如下: Array.from = $A; (function() { //Array原型的引用 var arrayProto = Array.prototype, slice = arrayProto.slice, //JS 1.6里面会有原生的forEach方法 _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available function each(it
-
Prototype Template对象 学习
复制代码 代码如下: var Template = Class.create({ //初始化方法 initialize: function(template, pattern) { this.template = template.toString(); this.pattern = pattern || Template.Pattern; }, //格式化方法,如果从java的角度来说,其实叫format更好 :) evaluate: function(object) { //检查是否
随机推荐
- Angular 4 依赖注入学习教程之FactoryProvider的使用(四)
- 原生JavaScript实现异步多文件上传
- Java基于JavaMail实现向QQ邮箱发送邮件
- Java多线程编程中synchronized线程同步的教程
- 自定义应用程序配置文件(app.config)
- python爬取网站数据保存使用的方法
- C#简单获取时间差的小例子
- MySQL数据库遭到攻击篡改(使用备份和binlog进行数据恢复)
- asp DateDiff实现文字在特定时间后消失
- jquery 输入框数字限制插件
- 每天对着电脑的人应该进来看看的图片
- Node.js的项目构建工具Grunt的安装与配置教程
- jquery固定底网站底部菜单效果
- Python使用scrapy采集数据过程中放回下载过大页面的方法
- vc中SendMessage自定义消息函数用法实例
- php获取bing每日壁纸示例分享
- 全面优化V4.0及AJAX标签使用技巧
- 浅谈es6中export和export default的作用及区别
- Laravel框架分页实现方法分析
- Java事件监听机制讲解