Test, validate and match regular expressions
This PCRE2 regex captures 2-4 characters, then matches any single character, followed by either the entire captured group repeated or just its last character. It's useful for identifying repetitive text patterns or validating strings where substrings must mirror earlier content. The pattern leverages backreferences to detect duplication.