RegEx: match any non-word and non-digit character except
java, regex
Solution
First of all, you must know that `\W` is equivalent to `[^a-zA-Z0-9_]`. So, you can change your current regex to:
[\\W]
This will automatically take care of `\D`.
Now, if you want to ignore some other character, say `&` (underscore is already exluded in `\W`), you can use negated character class:
[^\\w&]
Problem
To match any non-word and non-digit character (special characters) I use this: `[\\W\\D]`. What should I add if I want to also ignore some concrete characters? Let's say, underscore.