I'm stuck on making this Regex. I tried using look-ahead and look-behind together, but I couldn't use the capture group in the look-behind. I need to extract characters from a string ONLY if it occurs 4 times.
If I have these strings
- 3346AAAA44
- 3973BBBBBB44
- 9755BBBBBBAAAA44
The first one will match because it has 4 A's in a row. The second one will NOT match because it has 6 B's in a row. The third one will match because it still has 4 A's. What makes it even more frustrating, is that it can be any char from A to Z occuring 4 times.
Positioning does not matter.
EDIT: My attempt at the regex, doesn't work.
(([A-Z])\2\2\2)(?<!\2*)(?!\2*)