Tell us what’s happening:
I am confused by the solution and how it works.
why do I need ‘^’ at the beginning and '' in the end and why does my code not return true when the regex is "/(\d+)(\s)\1\2\1/g"? Also, my knowledge of why I need ‘$’ at the end of the pattern is still iffy. Please elaborate on that too. Thanks!!
Your code so far
let repeatNum = "42 42 42 42"; let reRegex = /^(\d+)(\s)\1\2\1$/g; // Change this line let result = reRegex.test(repeatNum); console.log(result);
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.61.
Challenge: Reuse Patterns Using Capture Groups
Link to the challenge: