I am trying to create a regex to validate usernames which should match the following :
regex
(._-)
I think you need to use ? instead of +, so the special character is matched only once or not.
?
+
^(?=(?![0-9])?[A-Za-z0-9]?[._-]?[A-Za-z0-9]+).{3,20}