I cannot figure out the regex pattern for my particular case. On an input form, I'm trying to validate a URI and do not want the client to be able to input either any absolute path or a relative path if it contains '../'.
I have no idea why this one is stumping... so far I've got ^([^.{2}/])(?!\.\.\/), but this one doesn't detect if the URIs have an arbitrary number of '../' strings in the middle of it. I tried ^([^.{2}/])(?!(\.\.\/)+) as well, but for some reason the URIs with '../' in the middle still fail.
My tests are:
(BAD)
/my/path
../my/path
/my/../path
my/../path
my/../../path
my/../path/../is/bad
(GOOD)
my/path
./my/path
my/./path
I appreciate the help!