Capture group issu

Capture group issu


Hi fellow Campers,
I am stuck at Capture groups challenge
Here is my solution:

let repeatNum = "101 102 103";
let reRegex = /(\d+)\s(\d+)\s\1/; // Change this line
let result = reRegex.test(repeatNum);
let result1 = repeatNum.match(reRegex);


And I admit that I don’t fully understand what’s happening and didn’t find a good tut to simplify it to me. So if you know one please attach the link.
Any help appreciated


Can you paste a link to the exercise?



Capture groups are created when you use just parenthesis. The idea behind it is to be able to reuse that group throughout the regex much like creating a variable.

let regex = /(yaba)(daba)\1\2\1/

In this regex the “\1” refers to the first set of parenthesis, and the “\2” refers to the second. this is equivalent to making a regex that has this.

let regex = /yabadabayabadabayaba/

I use RegExr to help me build regex when I need to. It allows you to see what will match without running console logs over and over.


Bro I am not sure that I understand it well but the website is awesome and very helpful. Thank you