Regular Expressions - Reuse Patterns Using Capture Groups

Tell us what’s happening:
Describe your issue in detail here.
Not sure why, but “42 42 42 42” seems to match the regular expression I entered. However, I only accounted for three duplicates. Where is the fourth coming from?

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Regular Expressions - Reuse Patterns Using Capture Groups

Link to the challenge:

I’m going to admit that I had to figure this one out again.

Big Hint: There are only two characters missing from your regex that will solve this challenge. One is at the very beginning and one is at the very end. They signal the start and end of a regular expression and tell that specific regular expression to only start with a digit group and end with the 3 duplicate matches.

You’re very close!

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