Reputation: 53129
I want to match all the words that do not contain letter l
. I tried this:
[a-z^k]+
But apparently ^
only works right behind [
. If it was just letter l
, I guess this would do:
[a-km-z]+
Of course apart from the fact that it just treats l
-words as two words:
But this is not the real concern, the question remains just as in title:
Q: How do I search for list of characters, but exclude another list of characters?
Upvotes: 4
Views: 11919
Reputation: 67968
You need to use \b
word boundary to make sure that the match doesn't start and end within words.
\b[a-km-z]+\b
Alternatively, you can create an exclusion list using lookahead.
\b(?:(?![l])[a-z])+\b
Upvotes: 8