include::../description.adoc[] == Noncompliant Code Example [source,javascript] ---- const date = "01/02"; const datePattern = /(?\d{2})\/(?\d{2})/; const dateMatched = date.match(datePattern); if (dateMatched !== null) { checkValidity(dateMatched[1], dateMatched[2]); // Noncompliant - numbers instead of names of groups are used checkValidity(dateMatched.groups.day); // Noncompliant - there is no group called "day" } // ... const score = "14:1"; const scorePattern = /(?\d+):(?\d+)/; // Noncompliant - named groups are never used const scoreMatched = score.match(scorePattern); if (scoreMatched !== null) { checkScore(score); } ---- == Compliant Solution [source,javascript] ---- const date = "01/02"; const datePattern = /(?\d{2})\/(?\d{2})/; const dateMatched = date.match(datePattern); if (dateMatched !== null) { checkValidity(dateMatched.groups.month, dateMatched.groups.year); } // ... const score = "14:1"; const scorePattern = /(?\d+):(?\d+)/; const scoreMatched = score.match(scorePattern); if (scoreMatched !== null) { checkScore(scoreMatched.groups.player1); checkScore(scoreMatched.groups.player2); } ----