toLocaleString (RegExp - JavaScript)

Gets a string representation of a regular expression taking into account the host locale.

Defined in

RegExp (Standard - JavaScript)

Syntax

toLocaleString() : string
Return value Description
string The string representation 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.
Note: This method appears to return as a string the type of the object, that is, [object RegExp].

Examples

This example writes the locale string of a regular expression to a global variable.
var re = new RegExp("(Moscow)");
requestScope.y = re.toLocaleString()