开发者

RegExp for matching three letters, but not text "BUY"

I have two buttons on form, one of the buttons contain currency code (EUR, USD, GBP,CHF,..) and another one - trade direction (BUY or SELL). And some utility recognize buttons by it's text. To recognize button with currencies, I use Regular expression ":[A-Z]{3}", but it don't work properly when second button contain text "BUY" (regex description returns m开发者_高级运维ore than one object).

Question: how can I write pattern for Regular expression, which means: match only when text contain three upper letters, but not text "BUY"?

Thanks!


^(?!BUY)[A-Z]{3}$

(?!BUY) is negative lookahead that would fail if it matches the regex BUY


You can use a negative look-behind assertion to verify that the text just matched does not equal BUY.

[A-Z]{3}(?<!BUY)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜