How is this right?

Tell us what’s happening:

This regex is getting answer. But i think it should also match “42 42 42 42”. But it is not and i will love to know why?
Please help me !!

Your code so far

let repeatNum = "42 42 42";
let reRegex = /^(\d+)(\s)\1\2\1$/; // Change this line
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/85.0.4168.3 Safari/537.36.

Challenge: Reuse Patterns Using Capture Groups

Link to the challenge:

The ^ and $ signify the beginning and end of the string.

Thanks a lot for quick response but sir according to me it will also match to “42 42 42 42”
as it has “42 42 42” in the beginning and “42 42 42” in the end. Please elaborate sir.
Thanks a lot!

You have one number capture group at the beginning, one whitespace, one number capture group, one whitespace, and one number capture group at the end. Any deviation from that will fail.