Regular Expressions and negating a whole character group [duplicate]

I’m attempting something which I feel should be fairly obvious to me but it’s not. I’m trying to match a string which does NOT contain a specific sequence of characters. I’ve tried using [^ab], [^(ab)], etc. to match strings containing no ‘a’s or ‘b’s, or only ‘a’s or only ‘b’s or ‘ba’ but not match on ‘ab’. The examples I gave won’t match ‘ab’ it’s true but they also won’t match ‘a’ alone and I need them to. Is there some simple way to do this?

9 Answers
9

Leave a Comment