DEV Community

loading...

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

boyukbas profile image baris ・1 min read

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…

Discussion (0)

pic
Editor guide