First of all, you should know that \W equivalent to [^a-zA-Z0-9_] . So you can change the current regular expression like this:
[\\W]
This will automatically take care of \D
Now, if you want to ignore any other character, say & (underscore is already excluded in \W ), you can use a negative character class:
[^\\w&]
source share