how to match a group earlier in the regex? #1263
Replies: 1 comment
-
The very first paragraph of the crate docs has your answer, emphasis mine:
You'll either need to use a different regex engine, not use regexes, or match more than you need and filter out matches after the fact based on checking group equality. |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm attempting complete one of the Advent of code puzzles back from 2015 and it's asking to find a pair of characters that repeats at least twice without overlapping in the input.
I'm attempting to use regex for this and the string
r"\b(\w{2}).*?\1\b"
seems to be the right path, but the regex fails saying that backreferences are not supported.Am I missing something on how to handle making sure that the capture group is listed twice in the string?
Beta Was this translation helpful? Give feedback.
All reactions