Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

The RegExp.prototype property represents the prototype object for the RegExp constructor.

Property attributes of RegExp.prototype
Writable no
Enumerable no
Configurable no

Description

See RegExp for a description of RegExp instances. RegExp instances inherit from RegExp.prototype. Modifications to the prototype object are propagated to all RegExp instances.

Properties

See also deprecated RegExp properties.

Note that several of the RegExp properties have both long and short (Perl-like) names. Both names always refer to the same value. Perl is the programming language from which JavaScript modeled its regular expressions.

RegExp.prototype.constructor
Specifies the function that creates an object's prototype.
RegExp.prototype.flags
A string that contains the flags of the RegExp object.
RegExp.prototype.global
Whether to test the regular expression against all possible matches in a string, or only against the first.
RegExp.prototype.ignoreCase
Whether to ignore case while attempting a match in a string.
RegExp.prototype.multiline
Whether or not to search in strings across multiple lines.
RegExp.prototype.source
The text of the pattern.
RegExp.prototype.sticky
Whether or not the search is sticky.
RegExp.prototype.unicode
Whether or not Unicode features are enabled.

Methods

RegExp.prototype.compile()
(Re-)compiles a regular expression during execution of a script.
RegExp.prototype.exec()
Executes a search for a match in its string parameter.
RegExp.prototype.test()
Tests for a match in its string parameter.
RegExp.prototype[@@match]()
Performs match to given string and returns match result.
RegExp.prototype[@@replace]()
Replaces matches in given string with new substring.
RegExp.prototype[@@search]()
Searches the match in given string and returns the index the pattern found in the string.
RegExp.prototype[@@split]()
Splits given string into an array by separating the string into substring.
RegExp.prototype.toSource()
Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the Object.prototype.toSource() method.
RegExp.prototype.toString()
Returns a string representing the specified object. Overrides the Object.prototype.toString() method.

Specifications

Specification Status Comment
ECMAScript 3rd Edition (ECMA-262) Standard Initial definition. Implemented in JavaScript 1.1.
ECMAScript 5.1 (ECMA-262)
The definition of 'RegExp' in that specification.
Standard  
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'RegExp.prototype' in that specification.
Standard Added flags, sticky and unicode properties.
ECMAScript 2017 Draft (ECMA-262)
The definition of 'RegExp.prototype' in that specification.
Draft  

Browser compatibility

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)

See also

Document Tags and Contributors

 Last updated by: arai,