Prototype RegExp对象 学习

时间:2009-07-19    点击:176   
复制代码 代码如下:

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 PeriodicalExecuter对象 学习
Prototype String对象 学习
Prototype Template对象 学习
Prototype Number对象 学习
Prototype ObjectRange对象学习
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved