W3cubDocs

/JavaScript

RegExp.prototype

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

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support Yes Yes 1 Yes Yes Yes
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes Yes 4 Yes Yes Yes
Server
Node.js
Basic support Yes

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/prototype