HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>The exec() method returns the matched text if it finds a match, otherwise it returns null.</p> <button onclick="myFunction()">Click me</button> <p id="point"></p> <script> function myFunction(){ var str = "Pot I got is hot"; // Try to change "o" to "z" var pattern = new RegExp("o"); var result = pattern.exec(str); document.getElementById("point").innerHTML = result; } </script> </body> </html>
OUTPUT
×

Save as Private