Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

RegExp.prototype

概述

RegExp.prototype 属性表示 RegExp 构造函数的原型对象。

描述

查看 RegExp 了解更多关于 RegExp 实例的说明。

RegExp 实例继承 RegExp.prototype。修改该原型对象上的属性或方法会影响到所有的 RegExp 实例。

属性

查看已废弃的RegExp属性

注意,RegExp 对象的几个属性既有完整的长属性名,也有对应的类 Perl 的短属性名。两个属性都有着同样的值。JavaScript 的正则语法就是基于 Perl 的。

RegExp.prototype.constructor
创建该正则对象的构造函数。
RegExp.prototype.global
是否开启全局匹配,也就是匹配目标字符串中所有可能的匹配项,而不是只进行第一次匹配。
RegExp.prototype.ignoreCase
在匹配字符串时是否要忽略字符的大小写。
RegExp.prototype.lastIndex
下次匹配开始的字符串索引位置。
RegExp.prototype.multiline
是否开启多行模式匹配(影响 ^ 和 $ 的行为)。
RegExp.prototype.source
正则对象的源模式文本。
RegExp.prototype.sticky
是否开启粘滞匹配。
Properties inherited from Object:

方法

查看已废弃的RegExp方法

RegExp.prototype.exec()
在目标字符串中执行一次正则匹配操作。
RegExp.prototype.test()
测试当前正则是否能匹配目标字符串。
RegExp.prototype.toSource()
返回一个字符串,其值为该正则对象的字面量形式。覆盖了Object.prototype.toSource 方法.
RegExp.prototype.toString()
返回一个字符串,其值为该正则对象的字面量形式。覆盖了Object.prototype.toString() 方法。

规范

Specification Status Comment
ECMAScript 1st Edition. Implemented in JavaScript 1.1 Standard Initial definition.
ECMAScript 5.1 (ECMA-262)
RegExp
Standard  
ECMAScript 6 (ECMA-262)
RegExp.prototype
Release Candidate  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

 

文档标签和贡献者

标签: 
 此页面的贡献者: teoli, AlexChao, ziyunfei
 最后编辑者: teoli,