Since MySQL does not support reverse capture groups, the typical solution (\w).*\1
will not work. This means that any given solution will have to list all possible doublings. In addition, as far as I can tell, backlinks are not valid in expectations or drops, and MySQL does not support hopes and expectations.
However, you can break this down into two expressions and use the following query:
SELECT * FROM words WHERE word REGEXP '^[SEPIAN]{1,6}$' AND NOT word REGEXP 'S.*?S|E.*?E|P.*?P|I.*?I|A.*?A|N.*?N'
Not very pretty, but it works, and it should also be quite effective.
To maintain a specified limit for duplicate characters, use the following pattern for your secondary expression:
A(.*?A){X,}
Where A
is your character and X
is the number of allowed.
So, if you add another N
to your SEPIANN
line (total 2 N
s), your query will look like this:
SELECT * FROM words WHERE word REGEXP '^[SEPIAN]{1,7}$' AND NOT word REGEXP 'S.*?S|E.*?E|P.*?P|I.*?I|A.*?A|N(.*?N){2}'
source share