HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>Click on the button to see the difference between * and ? in regexp</p> <button onclick="myFunction()">Click me</button> <p id="point"></p> <script> var x = document.getElementById("point"); function myFunction(){ var str = "2 25 255"; var pattern1 = /25*/g; var pattern2 = /25?/g; var result1 = "* = " +str.match(pattern1); var result2 = "? = " +str.match(pattern2); x.innerHTML = result1 +"<br>"+ result2; } </script> </body> </html>
OUTPUT
×

Save as Private