Javascript examples for RegExp:Property
The global property returns true if the "g" modifier is set, otherwise it returns false.
Type | Description |
---|---|
Boolean | Returns true if the "g" modifier is set, false otherwise |
The following code shows how to Check whether or not the "g" modifier is set:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*from www. j a v a 2s . c o m*/ var str = "The following code shows how to !"; var patt1 = /to/g; var res = patt1.global; document.getElementById("demo").innerHTML = res; } </script> </body> </html>