[beta] Regex should reuse the capture group twice
See original GitHub issueChallenge reuse-patterns-using-capture-groups has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
let repeatNum = "42 42 42";
let reRegex = /(\d+\s)\1/; //
let result = reRegex.test(repeatNum);
As this regex is completely new to me, I’m not exactly sure if this is a bug, but if it isn’t the lessons don’t address it.
Here’s my error: Your regex should reuse the capture group twice.
I’ve gotten all the other tests to pass and I can’t figure out how to tell what it’s doing, but if all the other tests pass then my assumption is that it is running through the capture group twice.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Regex Question (Regular Expressions: Reuse Patterns Using ...
Your regex should reuse the capture group twice. Your regex should have two spaces separating the three numbers. Your regex should match “42...
Read more >Capture groups using reuse patterns - Stack Overflow
Use capture groups in reRegex to match numbers that are repeated only three times in a string, each separated by a space.
Read more >Regular Expressions - Reuse Patterns Using Capture Groups
In this regular expressions tutorial we reuse patters using capture groups. We're using regular expressions in conjunction with JavaScript ...
Read more >4 Practical Use Cases for Regular Expressions - Bits and Pieces
The capturing group (the parenthesis and everything inside it) saves the matching part and you can reference it with “$1”. If you had...
Read more >picocli - a mighty tiny command line interface
Picocli will instantiate this class when needed to capture command line argument values in the @Option and @Parameters -annotated fields and methods of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll take this up…
@voidbringer01 “Your reRegex tests only if it finds 3 numbers in a row. It needs to check whether a string starts with a number and ends with one, while containing 3 numbers. So in 42 42 42 42, it finds a pattern in it even thought its just an substring of it. To fix that instead of let reRegex= /(\d+)\s\1\s\1; use let reRegex=/^(\d+)\s\1\s\1$/; . ^- so that it starts with a number and $ so that it ends with a number.”
why is this the case?