Based on all the information in your question and comments, you're looking for strings that match the following requirements:
- Any number of alpha characters so long as the following doesn't exist:
- A substring of 3 lowercase letters containing a lowercase letter that is not in the set
[abc]
Given those requirements (you definitely had me scratching my head for a bit there), the following regular expressions should work:
See regex in use here
^(?:(?!(?=[a-z]{3})[abc]{0,2}[^abc])[a-zA-Z])+$
^(?:(?!(?=[a-z]{3})[abc]{0,2}[d-z])[a-zA-Z])+$
Thanks to @anubhava in the comments below this answer for providing a faster alternative (doesn't use tempered greedy token):
See regex in use here
^(?!.*(?=[a-z]{3})[abc]{0,2}[d-z])[a-zA-Z]+$
^
Assert position at the start of the line
(?:(?!(?=[a-z]{3})[abc]{0,2}[^abc])[a-zA-Z])+
Tempered greedy token matching any ASCII alpha character ensuring the following doesn't exist:
(?=[a-z]{3})
Positive lookahead ensuring the following 3 characters are lowercase ASCII alpha characters
[abc]{0,2}[^abc]
Matches between 0 and 2 characters from the set abc
, followed by at least one character not in the set abc
- The above basically ensures at least one lowercase letter not in our set
abc
exists within the lowercase substring of length 3
$
Assert position at the end of the line