Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Grouping Sub-expressions in a Regular Expression</title> </head> <body> <script> let str = "One day Gogo will go to school."; let regex1 = /(go)+/i; let regex2 = /(go)+/gi; let matches = str.match(regex1); // case-insensitive match console.log(matches); // expected output: ["Gogo", "go", index: 8, ...] matches = str.match(regex2); // global, case-insensitive match console.log(matches); // expected output: ["Gogo", "go"] </script> <p><strong>Note:</strong> Please check out the browser console by pressing the f12 key on the keyboard.</p> </body> </html>