Regular Expressions - Reuse Patterns Using Capture Groups

Tell us what’s happening: i have most of the criteria ticked off exept one that says : Your regex should not match the string 42\t42\t42 .
how would i implement that change?

Your code so far

let repeatNum = "42 42 42";
let reRegex = /^(\d+)\s\1\s\1$/; // 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/114.0.0.0 Safari/537.36

Challenge: Regular Expressions - Reuse Patterns Using Capture Groups

Link to the challenge:

i have read through the hints but i just dont understand how to exclude the t42\t42

Try using a tool like https://regex101.com/ and put your regex in there and tell me if you see anything that might also look for something you don’t want in the “explanation” in the upper right.

1 Like

Not OP but I was having that same problem, I solved it anyways, but I still wanted to know why it didn’t work how I first made it (which was very similar to OP), followed your instructions, the issue is that “\s” will capture any whitespace including \t so technically \t is considered a match for \s but the test wants you to restrict the results to an actual space and not just any whitespace.-

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