Answer to Your Question
You have to get a little fancy with it:
^((?!([a-z])([a-z])\3\2).)+$

Debuggex Demo
Some Hints
Since this is coming from regex golf puzzle 5 at http://regex.alf.nu/, I'll give you a couple of hints.
First, some clarification for readers not familiar with these puzzles: this is a puzzle, based on xkcd comic 1313. It's called "regex golf." You are given two lists and have to figure out how to match all elements in one but none in the other, using the shortest regex you can find. On the website in question, most of the puzzles have a pattern in one of the lists, and the goal is to figure out the rule that applies and either write a short regex applying that rule or, if it's shorter, a regex that ignores the rule but just happens to work. In this case, you want to match words that don't have an abba
(or itti
, or whatever) pattern in their letters.
Hint 1: This is shorter, because it replaces [a-z]
with \S
:
^((?!(\S)(\S)\3\2).)+$

Debuggex Demo
Hint 2: While both regexes above work, neither is by any means the shortest working regex for the puzzle. The shortest working regex is a "cheat" in that it doesn't literally match the pattern, but nonetheless discriminates correctly between lists.