开发者

How can I build the regex to match a string NOT containing "au=1"?

As the title says... :)

Could you help me to build a regex to match a strings NOT containing "au开发者_StackOverflow社区=1"?

I was playing with negative lookahead with no luck but I'm quite sure that I should get something using that.

Thanks!


Using negative lookbehind:

?<!au=1

Negative lookahead will only look ahead, making the regex match match against au=1match. You should read up on the differences in more detail here.


You can also just match against au=1 and negate the result:

if(!Regex.IsMatch(input, @"au=1"))
{
    //  blah blah blah
}


Prefix the pattern with ! to negate it:

!au=1


I finally did it with this regexp

^(?!.*au=1).*$
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜