Revision 488275 of RegExp.prototype.toSource()

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

Revision Content

{{JSRef("Global_Objects", "RegExp")}} {{Non-standard_header}}

Summary

The toSource() method returns a string representing the source code of the object.

Syntax

regexObj.toSource()
Regex.toSource()

Parameters

None.

Description

The toSource method returns the following values:

  • For the built-in RegExp object, toSource returns the following string indicating that the source code is not available:
function RegExp() { [native code] }
  • For instances of RegExp, toSource returns a string representing the source code.

This method is usually called internally by JavaScript and not explicitly in code.

Specifications

Not part of any standard. Implemented in JavaScript 1.3.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatUnknown() }} {{ CompatVersionUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatVersionUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

  • {{jsxref("Object.prototype.toSource()")}}

Revision Source

<div>
 <div>
  {{JSRef("Global_Objects", "RegExp")}} {{Non-standard_header}}</div>
</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code><strong>toSource()</strong></code> method returns a string representing the source code of the object.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<code><em>regexObj</em>.toSource()
Regex.toSource()
</code></pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<p>None.</p>
<h2 id="Description" name="Description">Description</h2>
<p>The <code>toSource</code> method returns the following values:</p>
<!--This shouldn't be here, but until reorganization where pages are moved to their proper places, the title of this article is ambiguous, so it can stay. After reorganization, this should be removed.-->
<ul>
 <li>For the built-in <code>RegExp</code> object, <code>toSource</code> returns the following string indicating that the source code is not available:</li>
</ul>
<pre>
<code>function RegExp() { [native code] }</code></pre>
<ul>
 <li>For instances of <code>RegExp</code>, <code>toSource</code> returns a string representing the source code.</li>
</ul>
<p>This method is usually called internally by JavaScript and not explicitly in code.</p>
<h2 id="Specifications">Specifications</h2>
<p>Not part of any standard. Implemented in JavaScript 1.3.</p>
<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>{{ CompatUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</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>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatVersionUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<h2 id="See_Also" name="See_Also">See also</h2>
<ul>
 <li>{{jsxref("Object.prototype.toSource()")}}</li>
</ul>
Revert to this revision