<html> <head> <script> function testMatch() { var str = textfield.value; var pat = str.match(/student/g); if (pat != null) { alert("The string "+ str + "contains student."); } else { alert("The string " + str + "does not contain student."); } } </script> </head> <body> <h3> Checking the availability of word in given String. </h3> Enter the String: <input type="text" id="textfield" /> <input type="button" value="Check" onclick="testMatch();" /> </body> </html>