You avoid too much
/^[a-z0-9/. -]+$/i
In the character class, only [
, ]
, \
, -
and ^
have a special meaning, ^
even if it is only the first character and -
if it is between characters.
To match a literal ^
, just put it in any position except the first. To fit the letter -
literally, do not put it between characters (i.e., at the beginning or at the end).
Dump things like /
,. or $
, never required.
source share