I know i can do something like ab[^c]+def which should match ab_blah_hi_blah_def but is there a way to do something like
ab(^hi)+def
开发者_StackOverflow中文版
which will exclude the word hi causeing ab_blah_hi_blah_def to fail? but not ab_blah_h_i_blah_def
You can use a negative lookahead to do something like this. The pattern (?!foobar).
matches every character, except the f in "foobar".
So to match every word but "hi", you could use ^((?!hi)\w)+$
.
精彩评论