javascript - Regex to match mostly alphanumeric paths -
i tried creating regular expression verify path names filesystem api write using gridfs.
my current regex ^[a-za-z0-9\-\[\]()$#_./]*$
can fulfill criteria:
- allow
a-z
,a-z
,0-9
,-[]()$#_./
however doesn't meet these additional criteria:
- first character has
/
- there mustn't occurrence of multiple
/
in row.
questions:
- can me fix regex?
- are there possible issues using criteria path names? (did miss important?)
not sure path criteria, regarding regexp, pretty simple:
^\/(?!\/)([a-za-z0-9\-\[\]()$#_.]|(\/(?!\/)))*$
\/(?!\/)
means slash /
not followed slash (?!\/)
. used twice, once first character, , again 1 of possible matches after first character.
Comments
Post a Comment