I am not sure why the 4th item 42 in the string “42 42 42 42” is also matching as true with the below regex /(\d*)\s\1\s\1$/;
Can anyone please comment and explain why the 4th number which is differentiated by space is also matching
Your code so far
let repeatNum = “42 42 42 42”;
let reRegex = /(\d*)\s\1\s\1$/; // Change this line
let result = reRegex.test(repeatNum);
console.log(result);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.