As the title says: I want the input to be one or more symbols that is not in the union of letters, numbers and white space. So basically any of ~!@#, etc
. I have
"^(?=.*[[^0-9][^\w]])(?=\\S+$)$"
I know I could negate the appropriate set, but I don't know how to create my super set to start with. Would the following do?
"^(?=.*[(_A-Za-z0-9-\\+)])(?=\\S+$)$"
Maybe you're looking for \p{Punct}
, which matches any of !"#$%&'()*+,-./:;<=>?@[]^_`{|}~
.
String re = "\\p{Punct}+";
The class:
[^\w\s]
This will match any non-alphanumeric/non-whitespace character.
Java String
:
String regex = "[^\\w\\s]";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With