问题
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.
回答1:
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&]
来源:https://stackoverflow.com/questions/18244482/regex-match-any-non-word-and-non-digit-character-except