title: Postgresql Nested functions
body: <p>I'm trying to nest functions in postgresql, trying to extract a directory name (actually the third one) from a path.</p>
  
  <p>My starting SQL code was :</p>
  
  <pre><code>SELECT "Path", regexp_matches("Path", '^([^/]*/){3}.*') FROM ...
  </code></pre>
  
  <p>Since the returned value of my regex is delimited by curly brace and double-quote (when containing spaces), I'm trying to remove theses delimiters by nesting functions :</p>
  
  <pre><code>SELECT "Path", right(regexp_matches("Path", '^([^/]*/){3}.*'),2) FROM 
  </code></pre>
  
  <p>But I've the following error :</p>
  
  <pre><code>ERROR:  function right(text[], integer) does not exist
  LINE 2: SELECT "Path", right(regexp_matches("Path", '^([^/]*/){3}.*'...
                         ^
  HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
  État SQL :42883
  Caractère :17
  </code></pre>
  
  <p>I don't know how to format the expression in order to be accepted...</p>
  
  <p>Of course, if someone can give me a way to get exactly the nth field of a string separated by slashes, I would be happy !</p>