Prev Demo
JavaScript
>
Characters In String
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <h1>Finding characters in a String.</h1> String <input type="text" name="txtName" id="txtName" value="This is a good boy" /> string to find <input type="text" name="txtFind" id="txtFind" value="iss" /> <input type="button" name="btnTestfunction" value="Find" onclick="TestFunction()" /> <script> function TestFunction() { var string = document.getElementById("txtName").value; var toFind = document.getElementById("txtFind").value; var find = new RegExp(toFind); alert(find.test(string)); } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output