I seek to validate that a string
complies with this format:
- containing letters and numbers
- Whether or not the string may contain the characters
-
(middle dash) and_
(underscore)
I've done various tests, adding and removing more parameters to a regex
I made, but it doesn't work the way I want it to.
My regex:
[\w_-]+
It works partially, since it indicates that it contains alfanumericos
and -
_
, but when entering a string like this: ho-la._23
, it ignores ._23
since it finds the character .
and allows to continue when finding ho-la
since that does comply with the validation. What I am looking for is that when entering that string ho-la._23
or some other string that contains another character that is not alfanumérico
or _
-
, it does not allow matching.