I am trying to write a regular expression to match a file path with the following characteristics:
- do not contain
/./or/../ - at least one subdirectory located inside
/tmp/media - must end in
.log
Here is what I have so far:
\/tmp\/media\/(?!.*\.?\.\/)+(?:.*\.log)
Here are my desired results (if the string does not match, I refer to a requirement that fails):
/tmp/media/log.log
/tmp/media/test/log.log
/tmp/media/../log.log
/tmp/media/./log.log
/tmp/media/test/../log.log
/tmp/media/../test/log.log
/tmp/media/.t/log.log
/tmp/media/.../log.log
/tmp/log.log
/tmp/media/test/log.notlog
/tmp/media/test/./log.log
I read this question and successfully completed part of the answer, but /tmp/media/log.log still fits when I don't want it. I suspect that this is because an empty line between /media/and log.logsomehow satisfies (?!.*\.?\.\/).
- , , ?