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



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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ 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.

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

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