mozilla

Revision 417431 of RegExp.prototype.toString()

  • Revision slug: Web/JavaScript/Reference/Global_Objects/RegExp/toString
  • Revision title: toString
  • Revision id: 417431
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 6 words added, 11 words removedJavaScript/Reference/Global_Objects/RegExp/toString Web/JavaScript/Reference/Global_Objects/RegExp/toString

Revision Content

 

Summary

Returns a string representing the specified object.

Method of RegExp
Implemented in JavaScript 1.1
ECMAScript Edition ECMAScript 3rd Edition

Syntax

regexp.toString()

Parameters

None.

Description

The RegExp object overrides the toString method of the Object object; it does not inherit Object.toString. For RegExp objects, the toString method returns a string representation of the regular expression.

Examples

Example: Using toString

The following example displays the string value of a RegExp object:

myExp = new RegExp("a+b+c");
alert(myExp.toString());       // displays "/a+b+c/"

See Also

Object.prototype.toString

{{ languages( { "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/RegExp/toString", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/RegExp/toString" } ) }}

Revision Source

<p>
 </p>
<h3 id="Summary" name="Summary"> Summary </h3>
<p>Returns a string representing the specified object.
</p>
<table class="standard-table"> <thead> <tr> <th class="header" colspan="2">Method of <a href="/en/JavaScript/Reference/Global_Objects/RegExp"><code>RegExp</code></a></th> </tr> </thead> <tbody> <tr> <td>Implemented in</td> <td>JavaScript 1.1</td> </tr> <tr> <td>ECMAScript Edition</td> <td>ECMAScript 3rd Edition</td> </tr> </tbody>
</table> <h3 id="Syntax" name="Syntax"> Syntax </h3>
<p><code><em>regexp</em>.toString()</code>
</p>
<h3 id="Parameters" name="Parameters"> Parameters </h3>
<p>None.
</p>
<h3 id="Description" name="Description"> Description </h3>
<p>The <code>RegExp</code> object overrides the <code>toString</code> method of the <code><a href="/en/JavaScript/Reference/Global_Objects/Object" title="en/JavaScript/Reference/Global_Objects/Object">Object</a></code> object; it does not inherit <code><a href="/en/JavaScript/Reference/Global_Objects/Object/toString" title="en/JavaScript/Reference/Global_Objects/Object/toString">Object.toString</a></code>. For <code>RegExp</code> objects, the <code>toString</code> method returns a string representation of the regular expression.
</p>
<h3 id="Examples" name="Examples"> Examples </h3>
<h4 id="Example:_Using_toString" name="Example:_Using_toString"> Example: Using <code>toString</code> </h4>
<p>The following example displays the string value of a <code>RegExp</code> object:
</p>
<pre>myExp = new RegExp("a+b+c");
alert(myExp.toString());       // displays "/a+b+c/"
</pre>
<h3 id="See_Also" name="See_Also"> See Also </h3>
<p><a href="/en/JavaScript/Reference/Global_Objects/Object/toString" title="en/JavaScript/Reference/Global_Objects/Object/toString">Object.prototype.toString</a>
</p>{{ languages( { "ja": "ja/Core_JavaScript_1.5_Reference/Global_Objects/RegExp/toString", "pl": "pl/Dokumentacja_j\u0119zyka_JavaScript_1.5/Obiekty/RegExp/toString" } ) }}
Revert to this revision