Visit Mozilla.org

Core JavaScript 1.5 Reference:Global Objects:RegExp:toString

From MDC


Contents

[edit] Summary

Returns a string representing the specified object.

Method of RegExp
Implemented in: JavaScript 1.1, NES2.0
ECMA Version: ECMA-262, Edition 3

[edit] Syntax

regexp.toString()

[edit] Parameters

None.

[edit] 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.

[edit] Examples

[edit] 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/"

[edit] See Also

Object.prototype.toString