RegExp.prototype

  • Revision slug: Web/JavaScript/Reference/Global_Objects/RegExp/prototype
  • Revision title: RegExp.prototype
  • Revision id: 487533
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment cleanup

Revision Content

{{JSRef("Global_Objects", "RegExp")}}

Summary

The Regex.prototype property represents the prototype object for the {{jsxref("Global_Objects/RegExp", "RegExp")}} constructor.

Description

See {{jsxref("Global_Objects/RegExp", "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.

constructor
Specifies the function that creates an object's prototype.
{{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.lastIndex")}}
The index at which to start the next match.
{{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.
{{ jsOverrides("Object", "properties", "constructor", "global", "ignoreCase", "lastIndex", "multiline", "source", "sticky") }}

Methods

See also Deprecated RegExp Methods

{{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 Object.prototype.toSource method.
{{jsxref("RegExp.prototype.toString()")}}
Returns a string representing the specified object. Overrides the {{jsxref("Object.prototype.toString()")}} method.
{{ jsOverrides("Object", "Methods", "exec", "test", "toSource", "toString") }}

See also

  • {{jsxref("Global_Objects/RegExp", "RegExp")}}
  • {{jsxref("Function.prototype")}}

Revision Source

<div>
 {{JSRef("Global_Objects", "RegExp")}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code><strong>Regex.prototype</strong></code> property represents the prototype object for the {{jsxref("Global_Objects/RegExp", "RegExp")}} constructor.</p>
<h2 id="Description" name="Description">Description</h2>
<p>See {{jsxref("Global_Objects/RegExp", "RegExp")}} for a description of <code>RegExp</code> instances.<code> RegExp</code> instances inherit from <code>RegExp.prototype</code>. Modifications to the prototype object are propagated to all <code>RegExp</code> instances.</p>
<h2 id="Properties" name="Properties">Properties</h2>
<p>See also <a href="/en-US/docs/JavaScript/Reference/Deprecated_Features#RegExp_Properties" title="en-US/docs/JavaScript/Reference/Deprecated_Features#RegExp_Properties">Deprecated RegExp Properties</a></p>
<p>Note that several of the <code>RegExp</code> 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.</p>
<dl>
 <dt>
  <code>constructor</code></dt>
 <dd>
  Specifies the function that creates an object's prototype.</dd>
 <dt>
  {{jsxref("RegExp.prototype.global")}}</dt>
 <dd>
  Whether to test the regular expression against all possible matches in a string, or only against the first.</dd>
 <dt>
  {{jsxref("RegExp.prototype.ignoreCase")}}</dt>
 <dd>
  Whether to ignore case while attempting a match in a string.</dd>
 <dt>
  {{jsxref("RegExp.prototype.lastIndex")}}</dt>
 <dd>
  The index at which to start the next match.</dd>
 <dt>
  {{jsxref("RegExp.prototype.multiline")}}</dt>
 <dd>
  Whether or not to search in strings across multiple lines.</dd>
 <dt>
  {{jsxref("RegExp.prototype.source")}}</dt>
 <dd>
  The text of the pattern.</dd>
 <dt>
  {{jsxref("RegExp.prototype.sticky")}}</dt>
 <dd>
  Whether or not the search is sticky.</dd>
</dl>
<div>
 {{ jsOverrides("Object", "properties", "constructor", "global", "ignoreCase", "lastIndex", "multiline", "source", "sticky") }}</div>
<h2 id="Methods" name="Methods">Methods</h2>
<p>See also <a href="/en-US/docs/JavaScript/Reference/Deprecated_Features#RegExp_Methods" title="en-US/docs/JavaScript/Reference/Deprecated_Features#RegExp_Methods">Deprecated RegExp Methods</a></p>
<dl>
 <dt>
  {{jsxref("RegExp.prototype.exec()")}}</dt>
 <dd>
  Executes a search for a match in its string parameter.</dd>
 <dt>
  {{jsxref("RegExp.prototype.test()")}}</dt>
 <dd>
  Tests for a match in its string parameter.</dd>
 <dt>
  {{jsxref("RegExp.prototype.toSource()")}} {{ Non-standard_inline() }}</dt>
 <dd>
  Returns an object literal representing the specified object; you can use this value to create a new object. Overrides the Object.prototype.toSource method.</dd>
 <dt>
  {{jsxref("RegExp.prototype.toString()")}}</dt>
 <dd>
  Returns a string representing the specified object. Overrides the {{jsxref("Object.prototype.toString()")}} method.</dd>
</dl>
<div>
 {{ jsOverrides("Object", "Methods", "exec", "test", "toSource", "toString") }}</div>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
 <li>{{jsxref("Global_Objects/RegExp", "RegExp")}}</li>
 <li>{{jsxref("Function.prototype")}}</li>
</ul>
Revert to this revision