valueOf (RegExp - JavaScript)

Gets a string representation of a regular expression.

Defined in

RegExp (Standard - JavaScript)

Syntax

valueOf() : string
Return value Description
string The value of the regular expression, that is, the part that falls between the forward slashes when specified as a literal.

Usage

This value represents only the expression and does not include the flags.

Examples

This example writes (Moscow) to a global variable.
var re = new RegExp("(Moscow)");
requestScope.y = re.valueOf()