{{JSRef}}
The RegExp.prototype
property represents the prototype object for the {{jsxref("RegExp")}} constructor.
{{js_property_attributes(0, 0, 0)}}
Description
See {{jsxref("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 {{jsxref("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.
- {{jsxref("RegExp.prototype.flags")}}
- A string that contains the flags of the
RegExp
object. - {{jsxref("RegExp.prototype.global")}}
- Whether to test the regular expression against all possible matches in a string, or only against the first.
- {{jsxref("RegExp.prototype.ignoreCase")}}
- Whether to ignore case while attempting a match in a string.
- {{jsxref("RegExp.prototype.multiline")}}
- Whether or not to search in strings across multiple lines.
- {{jsxref("RegExp.prototype.source")}}
- The text of the pattern.
- {{jsxref("RegExp.prototype.sticky")}}
- Whether or not the search is sticky.
- {{jsxref("RegExp.prototype.unicode")}}
- Whether or not Unicode features are enabled.
Methods
- {{jsxref("RegExp.prototype.compile()")}} {{deprecated_inline}}
- (Re-)compiles a regular expression during execution of a script.
- {{jsxref("RegExp.prototype.exec()")}}
- Executes a search for a match in its string parameter.
- {{jsxref("RegExp.prototype.test()")}}
- Tests for a match in its string parameter.
- {{jsxref("RegExp.prototype.toSource()")}} {{non-standard_inline}}
- Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the {{jsxref("Object.prototype.toSource()")}} method.
- {{jsxref("RegExp.prototype.toString()")}}
- Returns a string representing the specified object. Overrides the {{jsxref("Object.prototype.toString()")}} method.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('ES3')}} | {{Spec2('ES3')}} | Initial definition. Implemented in JavaScript 1.1. |
{{SpecName('ES5.1', '#sec-15.10.5.1', 'RegExp')}} | {{Spec2('ES5.1')}} | |
{{SpecName('ES6', '#sec-regexp.prototype', 'RegExp.prototype')}} | {{Spec2('ES6')}} | Added flags , sticky and unicode properties. |
{{SpecName('ESDraft', '#sec-regexp.prototype', 'RegExp.prototype')}} | {{Spec2('ESDraft')}} |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
See also
- Regular Expressions chapter in the JavaScript Guide
- {{jsxref("RegExp")}}
- {{jsxref("Function.prototype")}}