Let's take a look at the syntax of regular expressions first.
We see that there are (? =a) and (?!) in regular expressions. A) to indicate whether we need to match something.
So we have the need to not match something when we can use (?!). a). Let's say we want to match strings that don't contain hello.
^(?!. *hello)
here. * to indicate that there may be other characters before the Hello, why should I add ^, because if not added, it may match to the position after H.
We can now solve the problem of ABBA on the Regex golf. The problem is to match words that do not contain ABBA, such as Abba,anallagmatic should not match. So that's all you need to do with this problem.
^(?!. *(.) (.) \2\1)
And then use the mismatch, we can also solve the problem of prime, this problem is to let us match a few x strings, first look at the regular.
^(?! (xx+) \1+$)
(xx+) is a match of 2 and more than 2 x, (xx+) \1+ is matching repeated occurrences of 2 or more strings, so (xx+) \1+ represents the strings of those not primes, then the prime string is to remove the number of primes, is the above regular expression.