Capture groups in regexp... I'm missing only one test

Tell us what’s happening:
Hi,
how can I limit my regexp match to pass the following test?:
Your regex should not match "42 42 42 42"

It’s the only test that I need to pass the challenge. I also read the solution but I did not understand it. Thanks!

Your code so far


let repeatNum = "42 42 42";
let reRegex = /(\d+)(\s)\1\2\1/; 
let result = reRegex.test(repeatNum);

Your browser information:

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

Challenge: Reuse Patterns Using Capture Groups

Link to the challenge:

Hello~!

Currently your regex looks for three matching sets of digits, which is partially correct. The reason that 42 42 42 42 passes is it contains three matching sets of digits.

Is there a way to tell your regex to only match exactly three sets?

Hint The "start of string" and "end of string" regex operators will be useful here.
1 Like