I want to use a regex to capture 3-6 characters
not containing a run of three of the same character. So, given AAABCDE, it would match AABCDE; and given ABCDDD, it would match ABCDD.
The most natural solution is to use lookbehind, starting with the third character, to check that the last three characters are not all the same:
/..(?:(.)(?<!\1\1\1)){1,4}/
The problem with that is that Perl's regex engine assumes that any backreference is variable-length, and variable-length lookbehinds are not allowed.
Originally posted as a Categorized Question.