JavaScript Program to Check Whether Given String contains a Word or not Using Regular Expression

Write a JavaScript program to check whether given string contains a word or not using regular expression.

Source Code
    <title>Regular expression to find given word</title>
        function check()
            var txt=document.getElementById('txt').value
            var re = /\bJavaScript\b/
            var res=re.test(txt)
                alert('Word found')
                alert('Word not found')			
Enter text <input type="text" id="txt"/>
<input type="button" value="Submit" onclick="check()"/>

"Coding Hub - Learn to code" app now available on Google Play Store