DEV Community

baris
baris

Posted on

Answer: Regular Expressions and negating a whole character group [duplicate]

Nice thread about regex

Use negative lookahead:

^(?!.*ab).*$

UPDATE: In the comments below, I stated that this approach is slower than the one given in Peter's answer. I've run some tests since then, and found that it's really slightly faster. However, the reason to prefer this technique over the other is not speed…

Top comments (0)