开发者

How do I match a word that starts with "I" but isn't the word "Integer"?

How do I write a regular expression that will match all words starting with I except the word Integer?

Example:

  t1: Integer;
  t2: Interface;
  t3: IXml;

The result开发者_如何学JAVA should be Interface and IXml.


This should do:

I(?!nteger\b)\w+


If you can’t use a look-ahead assertion as SilentGhost suggested, you can express the same using basic regular expression syntax:

I(\b|[A-Za-mo-z][A-Za-z]*|n(\b|[A-Za-su-z][A-Za-z]*|t(\b|[A-Za-df-z][A-Za-z]*|e(\b|[A-Za-fh-z][A-Za-z]*|g(\b|[A-Za-df-z][A-Za-z]*|e(\b|[A-Za-qs-z][A-Za-z]*|r[A-Za-z]+))))))


How about this :

I(?!nteger).*
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜