testRegExp = /search/i; if (testRegExp.test("this is a search string") { document.write("The string was found."); } else { document.write("No match found."); } We can place it in a Web page to test: <html><head> <title>RegExp test</title> </head><body> <script language="javascript"> testRegExp = /search/i; if (testRegExp.test("this is a search string")) { alert("The string was found."); } else { alert("No match found."); } </script></body></html>