Tell us what’s happening:
Describe your issue in detail here.
I don’t get why the test string "42 42 42 42"
shouldn’t match.
The Instruction is:
Use capture groups in reRegex to match a string that consists of only the same number repeated exactly three times separated by single spaces.
Based on the instructions my regex expression is /(\d+)\s\1\s\1/
.
But from what I understand the string "42 42 42 42"
should match since the string did contain 3 string of the same number separated by a single space. There is just an extra \s42
.
And should a string of "cab 24 42 42 42 is in the one"
be true as well? Since there is a number that repeats 3 times.
Am I wrong? or is the instruction not clear what I need to do?
Your code so far
let repeatNum = "cab 24 42 42 42 is in the one";
let reRegex = /(\d+)\s\1\s\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/95.0.4638.69 Safari/537.36 OPR/81.0.4196.60
Challenge: Reuse Patterns Using Capture Groups
Link to the challenge: