title: Regex to turn /01/02/007/... into 01/02 and /01 into 01/NA - is it possible?
body: <p>I have filesystem-like (but numerical) path of arbitrary length which I need to canonicalize to a fixed depth (2 or 3). Basically, I want this result:</p>
  
  <pre><code>/01/02/007/008  -&gt;  01/02/007
  /01/02/007      -&gt;  01/02/007
  /01/02          -&gt;  01/02/NA
  /01             -&gt;  01/NA/NA
  </code></pre>
  
  <p>I want to do with using Oracle's <code>regexp_replace()</code> function, which <a href="http://www.regular-expressions.info/oracle.html" rel="nofollow noreferrer">apparently impelements</a> the extended POSIX regexp standard.</p>
  
  <p>What I have so far is this: <code>regexp_replace(path,'/([^/]+(/[^/]+)?).*','\1');</code>
  But I'm having trouble with the <code>NA</code> part.</p>