开发者

Java regex pattern

Is there any way of excluding this characters: - \ _ to this pattern? I need especifically this pattern and no other

Pattern pattern = 开发者_JAVA百科Pattern.compile("[\\p{P}\\p{Z}]");


Use character class subtraction:

Pattern.compile("[\\p{P}\\p{Z}&&[^-_\\\\]]");


Generally to exclude a character you prepend it with ^. for example to match any number of characters that do not containt character 'a' you write:

[^a]*
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜