Q:

regex to capture all file paths not containing directory links

I am trying to write a regular expression to match file paths with the following characteristics:

do not contain /./ or /../
must be nested at least one subdirectory deep within /tmp/media
must end in .log

Here is what I have so far:
\/tmp\/media\/(?!.*\.?\.\/)+(?:.*\.log)

Here are my desired results (if the string doesn't match, I cite the requirement which is not satisfied):
/tmp/media/log.log             //NO-MATCH (2)
/tmp/media/test/log.log        //MATCH
/tmp/media/../log.log          //NO-MATCH (1)
/tmp/media/./log.log           //NO-MATCH (1)
/tmp/media/test/../log.log     //NO-MATCH (1)
/tmp/media/../test/log.log     //NO-MATCH (1)
/tmp/media/.t/log.log          //MATCH
/tmp/media/.../log.log         //MATCH
/tmp/log.log                   //NO-MATCH (2)
/tmp/media/test/log.notlog     //NO-MATCH (3)
/tmp/media/test/./log.log      //NO-MATCH (1)

I have read this question, and successfully implemented some of the answer, but /tmp/media/log.log is still matching when I do not want it to. I suspect it is because the empty string between /media/ and log.log somehow satisfies (?!.*\.?\.\/).
Can anyone explain what I'm doing wrong and help me correct my expression?

A:

You can try this:
^(?![^.]*\/\.\.?\/)\/tmp\/media\/(?:[^\/]+)*\/\w+\.log$

rubular link

