Regex challenge issue?

Regex challenge issue?
0.0 0

#1

I think I’ve found a glitch with a checking program.
My code is:

let repeatNum = "42 42 42";
let reRegex = /^(\d+)\s\1\s\1$/g; // Change this line
let result = reRegex.test(repeatNum);
alert(result)

And the alert says true, but the condition,
Your regex should match "42 42 42"
has a big ‘X’


10 major freeCodeCamp improvements that are live now
#2

What challenge exactly? There are a lot…
But your RegEx matches any number with spaces. It matches “1 1 1” too.


#3

I believe the OP is working on the following challenge, but not sure.

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/regular-expressions/reuse-patterns-using-capture-groups


#4

Weird, because on RegEx101 it matches “42 42 42”.

Remove the global flag from your RegEx and it should solve the challge. Im not sure why, but as I said on RegEx101 it matches “42 42 42”, even with the global flag.


#5

Yeah, thanks, that works now!
I’m guessing it’s just a picky criterium. I’ve had similar issues before.
Yeah, that was the challenge I was attempting, sorry for not mentioning that.