RegExp's toLocaleString() and toString()

toLocaleString() and toString() return the literal representation of the regular expression.

 
<!DOCTYPE html>
<html>
<head>
    <title>Example</title>
    <script type="text/javascript">
        var pattern = new RegExp("\\[oo\\]at", "gi"); 
        document.writeln(pattern.toString()); // /\[oo\]at/gi 
        document.writeln(pattern.toLocaleString()); // /\[oo\]at/gi 
       
    </script>
</head>
<body>
</body>
</html>
  
Click to view the demo

The valueOf() method for a regular expression returns the regular expression itself.

Home 
  JavaScript Book 
    Essential Types  

REGEXP:
  1. The Regexp Type
  2. RegExp constructor
  3. RegExp Instance Properties
  4. RegExp's exec() does the matching.
  5. RegExp's test()
  6. RegExp's toLocaleString() and toString()
  7. RegExp Constructor Properties