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]*
精彩评论