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

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -