JavaScript RegEx toString()

The JavaScript RegExp toString() method is used to retrieve a string to represent the regular expression.

Syntax:

RegExpObj.toString(); 

Return:
String representation of the regular expression.

Example

<!DOCTYPE html>
<html>
<body>
<script>
document.write (new RegExp("HELLO + WORLD").toString());	 
</script>
</body>
</html>

Output

/HELLO + WORLD/
Please Share