RegExp.toSource() (Method)

Outputs a regular expression object formatted as a RegExp literal contained in a string.

Availability:

JavaScript - 1.3
Netscape - 4.06
Property/method value type:String primitive
JavaScript syntax:NmyRegExp.toSource()

This is an alternative way to deliver a string version of a regular expression object. In this case, it is formatted as a RegExp literal and can then be used in an eval() function to assign another regular expression.