title: Regex to check if a path go only down
body: <p>I want to test if a path given by the user go down like:</p>
  
  <p><code>my/down/path</code></p>
  
  <p>at the opposite of:</p>
  
  <p><code>this/path/../../go/up</code></p>
  
  <p>for security reasons.</p>
  
  <p>I already made this:</p>
  
  <pre><code>return (bool)preg_match('#^([a-z0-9_-])+(\/[a-z0-9_-])*$#i', $fieldValue);
  </code></pre>
  
  <p>But the user should be allowed to use the <code>'.'</code> in his path (like: <code>my/./path</code>, that not useful but he can) and I don't know how to consider it.</p>
  
  <p>I'm then looking for a secure regex to check this.</p>
  
  <p>Thanks</p>
  
  <p>edit: After viewing answers, yes it would be fine if the test check if the real path (removing <code>'.'</code> and <code>'..'</code>) is a down path.</p>