Javascript examples for RegExp:Method
The toString() method returns the string value of the regular expression.
None.
Type | Description |
---|---|
String | The string value of the regular expression |
The following code shows how to return the string value of the regular expression:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*w ww. j av a 2s .co m*/ var patt = new RegExp("Hello World", "g"); var res = patt.toString(); document.getElementById("demo").innerHTML = res; } </script> </body> </html>