I\'ve made this regex:
^[a-zA-Z0-9_.-]*$
Supports:
letters [uppercase and lowercase]
numbers [from 0 to 9]
underscores [_]
The hyphen is being treated as a range marker -- when it sees ,-!
it thinks you're asking for a range all characters in the charset that fall between ,
and !
(ie the same way that A-Z
works. This isn't what you want.
Either make sure the hyphen is the last character in the character class, as it was before, or escape it with a backslash.
I would also point out that the quote characters you're using “”„
are part of an extended charset, and are not the same as the basic ASCII quotes "'
. You may want to include both sets in your pattern. If you do need to include the non-ASCII characters in the pattern, you should also add the u
modifier after the end of your pattern so it correctly picks up unicode characters.