Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Match a Single Character Using Regular Expression in JavaScript</title> </head> <body> <script> let regex = /ca[kf]e/; let str = "He was eating cake in the cafe."; // Test the string against the regular expression if(regex.test(str)) { document.write("Match found!"); } else { document.write("Match not found."); } </script> </body> </html>