Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 704755 of RegExp.prototype

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

Revision Content

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

Summary

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.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.
{{jsxref("RegExp.prototype.flags")}} {{experimental_inline}}
A string consists of the flags of a regex object.
{{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 {{jsxref("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. Standard 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')}}  

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 <strong><code>RegExp.prototype</code></strong> property represents the prototype object for the {{jsxref("RegExp")}} constructor.</p>
<div>
 {{js_property_attributes(0, 0, 0)}}</div>
<h2 id="Description" name="Description">Description</h2>
<p>See {{jsxref("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">deprecated <code>RegExp</code> properties</a></p>
<p>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.</p>
<dl>
 <dt>
  <code>RegExp.prototype.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>
 <dt>
  {{jsxref("RegExp.prototype.flags")}} {{experimental_inline}}</dt>
 <dd>
  A string consists of the flags of a regex object.</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">deprecated <code>RegExp</code> 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 {{jsxref("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.</td>
   <td>Standard</td>
   <td>Initial definition. Implemented in JavaScript 1.1.</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>
<div>
 {{CompatibilityTable}}</div>
<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">Regular Expressions</a> chapter in the <a href="/en-US/docs/Web/JavaScript/Guide">JavaScript Guide</a></li>
 <li>{{jsxref("RegExp")}}</li>
 <li>{{jsxref("Function.prototype")}}</li>
</ul>
Revert to this revision