Regex-Reuse Patterns Using Capture Groups

Tell us what’s happening:
Describe your issue in detail here.

I haven’t been working with regex for long. Even though I know that the ^...$ are used to show beginning and an end, I was wondering why we need to put them here in this context and how would the code execute without them?

Thanks :grinning_face_with_smiling_eyes:
Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.

Challenge: Reuse Patterns Using Capture Groups

Link to the challenge:

Have you tried experimenting to see what changes without those characters?
You can do that inside of freeCodeCamp, but regex101 is my favorite tool for fiddling with regular expressions.

1 Like

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