Reuse Patterns Using Capture Groups ==Solution

i think ,your hint is not correct and do not relation by challenge, correct solution is this :

let repeatNum = “42 42 42 42”;
let reRegex = /(\d+) (\1 \1 \1|\1 \1)/; // Change this line
let result = repeatNum.match(reRegex);

console.log(result);

thanks.

Which challenge are you taking about? Please provide the link. Thanks.

1 Like

Link to the challenge:

sorry , my solution is not correct for “42 42 42 42” it must not match, the Regex must return true only for 3 repeat and return false for 4 repeat; ( it must 3 repeat is match and 4 repeat or 2 repeat not match)

this is okay:

let repeatNum = “42 42 42 42”;

let reRegex = /^(\d+)\s\1\s\1$/; // Change this line

let result = reRegex.test(repeatNum);

let res = repeatNum.match(reRegex);

console.log(result);

console.log(res);

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.