开发者

Match opposite of regular expression

I have a quick question about Regular Expressions.

Can I specify a pattern and have everything else that doesnt开发者_开发百科 fit the pattern to be matched?

For example, anything that does not fit into this pattern: HT\d{4}, I want to consider a match.


yes, you can do this: (?!HT\d{4})

It's called a "negative lookahead". It is supported in most regex engines.


You can do something like ^.*$(?<!HT\d{4})

But in most languages, you can use the original regex and use a logical ! in the language. Like !Regex.IsMatch()

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜