Regular Expressions - Reuse Patterns Using Capture Groups

Tell us what’s happening:
Describe your issue in detail here.
Not sure exactly what I am doing wrong the error it is giving me is Your regex should not match the string

42\t42\t42

.

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

Challenge: Regular Expressions - Reuse Patterns Using Capture Groups

Link to the challenge:

You should not match any space character (like the tab character for example should not be matched).

Use only a single space in the match

sorry but i need a little more help ive tried for a while to figure this out now

Okay, so \s doesn’t just match whitespace. It matches tab characters too and if we think about what the \t in the 42\t42\t42 string means…?

Remember you can represent a space character in a regex by using a space character.

E.g.
/ /.test(" ");
(returns a value of true)

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