Tell us what’s happening:
my code should mean:
- Find a 1 or more digits followed by a space
- Repeat (1.) 2 times
The above interpretation is not right and i do not get it (i mean why it is wrong?).
Your code so far
let repeatNum = "42 42 42"; let reRegex = /(\d+\s)\2/; // Change this line let result = reRegex.test(repeatNum); console.log(result);
Second i do not understand the last two hints in the lessons; speaking specifically.
let testString = "test test test"; let reRegex = /(test)(\s)\1\2\1/; let result = reRegex.test(testString);
I do not understand specifically
\1\ & finally why did he use global?
let testString = "test test test test test test"; let reRegex = /(test)(\s)\1\2\1/g; let result = reRegex.test(testString);
I do not understand specifically why did he wrote
\s\1\s\1$ because (from what i understand) this means 4 spaces at the end.
Your browser information:
User Agent is:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36.
Challenge: Reuse Patterns Using Capture Groups
Link to the challenge: