Regular Expressions - Reuse Patterns Using Capture Groups

Understanding Capture groups :
Hi, can anyone explain why this code works… I don’t really understand it.
Thanks, have a great day!

Your code so far

let repeatNum = "42 42 42";
let reRegex = /^(\d+) \1 \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/113.0.0.0 Safari/537.36

Challenge: Regular Expressions - Reuse Patterns Using Capture Groups

Link to the challenge:

I spoilered the code because it is a solution.
Can you explain the bits which you do and do not understand about that regex?

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