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) { //检查是否
随机推荐
- flex小技巧之加载GIF图片
- javascript巧用eval函数组装表单输入项为json对象的方法
- 网络安全方面的专业词汇
- 详解iOS开发中使用storyboard创建导航控制器的方法
- QQ关于.net的精彩对话
- javascript实现表格增删改操作实例详解
- 需要使用php模板的朋友必看的很多个顶级PHP模板引擎比较分析
- Python正规则表达式学习指南
- python的迭代器与生成器实例详解
- PHP模块memcached使用指南
- node.js学习总结之调式代码的方法
- 用div+css解决出现水平滚动条问题
- javascript实现的简易的DatePicker日历
- jquery怎样实现ajax联动框(二)
- Kloxo面板无法登录出现500错误的解决方法
- LINUX 下软件包的安装与使用详解
- Java编程中实现归并排序算法的实例教程
- 雅虎公司C#笔试题(后半部份才是)
- python3大文件解压和基本操作
- 一种angular的方法级的缓存注解(装饰器)