let repeatNum = "42 42 42";
let reRegex = /(42) \3/; // Change this line
//this also doesn't work
// let reRegex = (\42+)\1\3/;
//or letRegex.match(\42\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.
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.