Replacing a Text Using Regular Expression



Write a javascript code to replace a text using regular expression


<html>
  <head>
    <script>
     
         function testMatch()
         {
            var str = "Student has PHP Textbook.";
            var b = str.replace("PHP", "javascript");
            document.write(b);
         }
             
    </script>
  </head>
<body>

         <h3> Original Statement: "Student has PHP Textbook" </h3>

         <p>Click the button to get the output.</p>

         <input type="button" value="Check" onclick="testMatch();" />

  </body>
</html>

Output: