I am trying to come up with a regex that I can use with the matches function to validate the user id I accept. The user id can contain alphabets, numbers and 3 special chars ".","-" and "#".
The regex I came up with was: user_id.matches("[a-zA-Z\\d\\.\\-#]"). The string I am trying to match is 'user-1'. But this fails to match.
I am not confident about the regex I am using to match my string to. Please let me know what I am doing wrong.