Tell us what’s happening:
Hi my initial answer for this challenge is /^(\d+)(\s)\1\2\1$/
which didn’t fit two of the requirements:
- Your regex should reuse the capture group twice.
- Your regex should have two spaces separating the three numbers.
Which I think you can say I didn’t use “two” spaces but “capture group of space”, but I am pretty sure I did reuse capture group twice.
Question
Using the testing method, myAnswer and fccAnswer both return true, so theoretically myAnswer should be accept as well?
Is there something I didn’t notice or Is it a wording problem after all? (Since I use “capture group of space” instead of “space” and reuse capture group “at least twice” instead of twice.)
Test
I tested some possibilities using the browser console:
let number = "42 42 42"
let myAnswer = /^(\d+)(\s)\1\2\1$/;
let fccAnswer = /^(\d+)\s\1\s\1$/;
// Testing
fccAnswer.test(number);//true
myAnswer.test(number);//true
fccAnswer.test("42");//false
myAnswer.test("42");//false
fccAnswer.test("42 42 42");//false
myAnswer.test("42 42 42");//false
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/reuse-patterns-using-capture-groups