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
RegExpobject. RegExp.prototype.dotAll- Whether
.matches newlines or not. 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[@@matchAll]()- Returns all matches of the regular expression against a string.
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 Latest Draft (ECMA-262) The definition of 'RegExp.prototype' in that specification. |
Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | Server | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
prototype | Chrome Full support Yes | Edge Full support Yes | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
Legend
- Full support
- Full support
See also
- Regular Expressions chapter in the JavaScript Guide
RegExpFunction.prototype