In my Java application, I’m trying to specify a Pattern that would match anything that’s not made up of either uppercase letters, lowercase letters, or dashes. So I want it to match anything that doesn’t contain A-Z, a-z, or ‘-‘. I’m new to using regular expressions so I just wanted to see if I was even close to getting this right. This is what I have:
Pattern.compile("[^A-Z]&&[^a-z]&&[^\\-]");
I’m not even sure if I need the escape characters for the dash or if I do, whether it should be two backslashes instead of one. I’m also not sure about the format overall. Thanks for any help.
Building off of @Joe’s answer:
But you need to use double backlash since you need to escape the
\which is escaping the-