I would like to build q regular expression that matches patterns of repeated single characters, followed by each other. For example three times the same character 'A' followed by two times another character 'B'. It doesn't matter if the second group's character is repeated more than two times. For instance it should match the string wuzDDDFFFxji
Full match 3-8 `DDDFF`
Group 1. 3-4 `D`
Group 2. 6-7 `F`
I've come up with the following regular expression but there's one limitation.
(.)\1{2}(.)\2{1}
It almost works but it will not exclude the first group's character from being matched in the second group. The string qwuiuQQQQQsas will be matched since:
Full match 5-10 `QQQQQ`
Group 1. 5-6 `Q`
Group 2. 8-9 `Q`
This doesn't match what I want but I couldn't find the correct syntax to exclude a specific group from being matched in another one. My closest attempt doesn't seem to work
(.)\1{2}((?:\1))\2{1}
1st Capturing Group (.)
. matches any character (except for line terminators)
\1{2} matches the same text as most recently matched by the 1st capturing group
{2} Quantifier — Matches exactly 2 times
2nd Capturing Group ((?:\1))
Non-capturing group (?:\1)
\1 matches the same text as most recently matched by the 1st capturing group
\2{1} matches the same text as most recently matched by the 2nd capturing group
{1} Quantifier — Matches exactly one time (meaningless quantifier)
Any hint here? Thank you so much!