Regular Expressions - Reuse Patterns Using Capture Groups

Tell us what’s happening:

let reRegex = /^(\d+) \1\s\1$/; // and
let reRegex = /^(\d+)  \1 \1$/; //pass the test but
let reRegex = /^(\d+) \s\1\s\1$/;  //not. It should be all or nothing.

Your code so far

let repeatNum = "42 42 42";
let reRegex = /^(\d+) \1\s\1$/; // Change this line
let result = reRegex.test(repeatNum);
console.log(result);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0

Challenge Information:

Regular Expressions - Reuse Patterns Using Capture Groups

the third option has more spaces, it can’t pass

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.