Reuse Patterns Using Capture Groups -Stuck hard


I don’t understand the numbering aspect of this, my logic was 3 repeats of \w+ and 2 repeats of \s. Or put another way, 3 numbers 2 spaces. But even then, my logic doesnt even make sense because how does it know that the first number specifies the repeat of the first capture group and the second number specifies the repeat of the secon capture group etc. Can anyone give an overview explanation? thanks.

Your code so far

let repeatNum = "42 42 42";
let reRegex = /(\w+)(\s)\3\2/; // Change this line
let result = reRegex.test(repeatNum);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge: