开发者

What is the right regex that matches one of the substrings at the end of the word in Java?

I ne开发者_开发百科dd the check whether the word ends with one of the _LNG , _DBL , _STR . My regex is

"_[(LNG|DBL|STR)]$"

but does work . Following must match but did'nt work. (I use java)

PARAM_LNG

I have tried following

"[(_LNG|_DBL|_STR)]$"

but it matchs with following although it has no underscore.

PARAMLNG

Can anyone show the right regex? Thanks.


Don't use [], that's a character class specification.

"_(LNG|DBL|STR)$"

Note that this will only match at the end of the string. Try:

"_(LNG|DBL|STR)\b"

to match any word ending with those suffixes inside a string.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜