I am searching for a particular kind of palindrome. The rules are

1. The length is 5;
2. In the first two characters, one should be a capitalized letter, and the other should be a digit;
3. The third character is a letter in lower case .

The main difficulty for me is the undetermined positions of the group references.
If I write `'(((([A-Z])([0-9]))|(([0-9])([A-Z])))[a-z]\5\4)'`, only `K2i2K` but not `2KiK2` will be matched. To match `2KiK2`, I have to write `'(((([A-Z])([0-9]))|(([0-9])([A-Z])))[a-z]\8\7)'`.

So how should I write the regular expression? Thank you.