Regular Expressions - Reuse Patterns Using Capture Groups

Tell us what’s happening:
it shouldn’t match 42 42 42 42 …I have added only 2 spaces not 3 in code (in reRegex ) then why it still matches I don’t understand.

Error :Your regex should not match the string

42 42 42 42

Your code so far

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

Challenge: Regular Expressions - Reuse Patterns Using Capture Groups

Link to the challenge:

This could be confusing, have you check out the GET HELP → HELP HINT section?
Usually , i will use ^ and $ to limit this search pattern to only 3 occurences.

1 Like

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