Exécuter
❯
Exécuter le code
Ctrl+Alt+R
Enregistrer le code
Ctrl+Alt+A
Changer d'orientation
Ctrl+Alt+O
Changer de thème
Ctrl+Alt+D
<!DOCTYPE html> <html> <body> <h1>Expressions régulières</h1> <h2>Groupes de capture nommés</h2> <p id="demo"></p> <script> const text = "Nom : John Doe"; // Utilisation de groupes de capture nommés const regex = /(?<firstName>\w+) (?<lastName>\w+)/; const match = text.match(regex); let fName = match.groups.firstName; let lName = match.groups.lastName; document.getElementById("demo").innerHTML = "Nom de famille : " + match.groups.lastName; </script> </body> </html>