mozilla

Revision 487987 of RegExp.prototype

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

Revision Content

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

Summary

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

{{js_property_attributes(0,0,0)}}

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.

RegExp.prototype.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")}} {{experimental_inline}}
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") }}

Specifications

Specification Status Comment
ECMAScript 1st Edition. Implemented in JavaScript 1.1 Standard Initial definition.
{{SpecName('ES5.1', '#sec-15.10.5.1', 'RegExp')}} {{Spec2('ES5.1')}}  
{{SpecName('ES6', '#sec-regexp.prototype', 'RegExp.prototype')}} {{Spec2('ES6')}}  

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

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>
<div>
 {{js_property_attributes(0,0,0)}}</div>
<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/Web/JavaScript/Reference/Deprecated_and_obsolete_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>RegExp.prototype.</code><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")}} {{experimental_inline}}</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/Web/JavaScript/Reference/Deprecated_and_obsolete_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="Specifications">Specifications</h2>
<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>ECMAScript 1st Edition. Implemented in JavaScript 1.1</td>
   <td>Standard</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ES5.1', '#sec-15.10.5.1', 'RegExp')}}</td>
   <td>{{Spec2('ES5.1')}}</td>
   <td>&nbsp;</td>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-regexp.prototype', 'RegExp.prototype')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Android</th>
    <th>Chrome for Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Mobile</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
 <li><a href="/en-US/docs/Web/JavaScript/Guide/Regular_Expressions" title="JavaScript/Guide/Regular_Expressions">Regular Expressions</a> chapter in the <a href="/en-US/docs/Web/JavaScript/Guide" title="JavaScript/Guide">JavaScript Guide</a></li>
 <li>{{jsxref("Global_Objects/RegExp", "RegExp")}}</li>
 <li>{{jsxref("Function.prototype")}}</li>
</ul>
Revert to this revision