Regular Expressions - Reuse Patterns Using Capture Groups

Tell us what’s happening:
they keep saying my regex should not match ```
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);


```javascript
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/113.0.0.0 Safari/537.36

Challenge: Regular Expressions - Reuse Patterns Using Capture Groups

Link to the challenge:

Yes, the issue is that \s is interpreted both as a single space and a tab (\t) by the regex engine, hence the error message. (It is also interpreted as a carraiage return (\r), newline (\n) and form feed (\f) too).
However, the easy way around this is simply to put a literal space into your regex, instead of \s.

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