(Sorry for the terrible pun.)
There are quite a few highly-upvoted questions on the topic of matching overlapping strings with regex:
- How can I match overlapping strings with regex?:
- Language: javascript
- Question score: 63.
- Highest answer score: 34.
- Accepted answer score: 23.
- Creation date: 2013
- Javascript Regex - Find all possible matches, even in already captured matches
- Language: javascript
- Question score: 17.
- Highest answer score (accepted): 25.
- Creation date: 2013
- Overlapping matches in Regex
- Language: c#
- Question score: 49.
- Highest answer score (accepted): 34.
- Creation date: 2008
- How to use regex to find all overlapping matches
- Language: python
- Question score: 146.
- Highest answer score (accepted): 249.
- Creation date: 2011
If I'm not terribly mistaken, the reference mentions none of them. Which should be chosen and added to the reference as the canonical question?
(?=(
))
or a variance thereof.(?=(mypattern))
, or manually iterate through string and apply your pattern from every position. Do you really think this answer must be repeated for every language?