I want to make a regex syntax for allowing me ASCII letters, digits, hyphens and underscores and forward slashes.
Currently I am using following syntax but it is not working
if (!id.matches("[a-zA-Z0-9_-/]+")) {
throw new IllegalArgumentException("Invalid ID: \"" + id
+ "\". An ID may not be the empty string and must contain only ASCII letters, digits, hyphens and underscores and forward slash.");
}
However when I remove the '/' from the regex it is working fine. How can I add forward slash in this condition?
I looked into regex tutorial and it has some examples but those are individual. I want to use forward slash along with ASCII letters, digits.
-."[a-zA-Z0-9_\-/]+")or move to the end in the character class"[a-zA-Z0-9_/-]+")documenation