I'm trying to kind of brute force a cipher text where I don't know what any of the characters are, but I do know the language, the length of each word and the position of all the characters.

One of the words in the text is "avarrm", so I was hoping I could loop through a dictionary of words and try to match only the ones where the character in the first position is the same as the one in the third position, and the character in the 4th position is the same as the one in the 5th position, with the remaining characters not being either of those two characters or the same as each other.

It sounds like a job for a regex, but I have absolutely no idea how I would go about writing it. Is this doable, and if so, how? Or should I forget about regex and do it with a bunch of ifs?