Tell us what’s happening:
I tried solving this but, keep failing. Why?
Your code so far
let repeatNum = "42 42 42";
let reRegex = /(42) \3/; // Change this line
//this also doesn't work
// let reRegex = (\42+)\1\3/;
let result = reRegex.test(repeatNum);
Your browser information:
User Agent is:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Safari/605.1.15.
Challenge: Reuse Patterns Using Capture Groups
Link to the challenge:
it seems you have not clear the capture groups syntax
also remember you need to match three consecutive numbers, not just
42 (do you know how to match a number? any number?)
what you put in the round parenthesis can be referenced again with
\1 the first captured group, with
\2 the second one, and so on.
Try again, do not have time for a more detailed explanation. Bye.
You have to use the shorthand character class for digits for this.
Try https://regex101.com/ to test your regex
let’s say I want to match two consecutive equal words
So I match the first word with
/[a-z]+/i, and if I add a capture group, I could match again exactly what the capture group has matched the first time:
/([a-z]+) \1/i, if I want to match the same word more times I can just add
\1 again, as many times as I want.
It needs something more than this, as the goal is to match exactly 3 times, not more. But try to do that on your own.