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 1005841 of RegExp.prototype

  • Revision slug: Web/JavaScript/Reference/Global_Objects/RegExp/prototype
  • Revision title: RegExp.prototype
  • Revision id: 1005841
  • Created:
  • Creator: SphinxKnight
  • Is current revision? No
  • Comment Revert to revision of 2016-01-04 05:14:24 by fscholz: "Per the spec, lastIndex is still an instance property (contrary to the other)"

Revision Content

{{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

Revision Source

<div>{{JSRef}}</div>

<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">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">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.flags")}}</dt>
 <dd>A string that contains the flags of the <code>RegExp</code> object.</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.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>
 <dt>{{jsxref("RegExp.prototype.unicode")}}</dt>
 <dd>Whether or not Unicode features are enabled.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{jsxref("RegExp.prototype.compile()")}} {{deprecated_inline}}</dt>
 <dd>(Re-)compiles a regular expression during execution of a script.</dd>
 <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>

<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>{{SpecName('ES3')}}</td>
   <td>{{Spec2('ES3')}}</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>Added <code>flags</code>, <code>sticky</code> and <code>unicode</code> properties.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-regexp.prototype', 'RegExp.prototype')}}</td>
   <td>{{Spec2('ESDraft')}}</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