regex - notepad++ - search for a string containing a string and not containing another string

notepad++, regex

Solution

Try using negative look ahead:

user = (?![aA][bB]).*

You are misunderstand how a character class works. The character class - `[ab]` matches only one character, out of all present inside `[` and `]`. So, it will match either `a` or `b`. I won't match `ab` in sequence. Basically `[ab]` is same as `a|b`.

Problem

I am not able to solve this: I have text file with some entries like "user = ABname". I would like to search for all the lines containing user id not beginning with "AB" or "ab" and I need to do it with a regular exp using the search functionality of Notepad++. I have tried using ``` user = ^[ab] ``` but actually is not working as expected. I should find all these: ``` user = CDname1 user = cdname2 user = acname3 user = xbname4 ``` but not ``` user = abname1 user = ABname2 ```

Original source