-
If you don't actually need a regular expression, eg you're using PCRE or similar, then you want a negative lookahead:
(beatrix(?!ie)|(?!bea)trixie)
It is possible to do it with standard regular expressions (since every regular language can be negated), but it's much more painful.
Edit: for completeness, here's what that would look like:
(?:(?:(?:[^b]|b(?:b|eb)*?(?:[^be]|e[^ab]))*?(?:b(?:b|eb)*e?)??(trixie))|(?:(beatrix)(?:(?:[^i]|i+[^ei])*?i*?)))
(?: )
is a non-capturing group,*?
and??
are lazy (rather than greedy) matching, negations constructed using this tool http://www.formauri.es/personal/pgimeno/misc/non-match-regex/As you can see, it gets messy fast.
Anybody good at regex? If I have
How do I specify that if there is one instance of Bea there must be zero instances of ie and vice versa?