title: regex for nested mark-up/functions
body: <p>I am creating a program where I offer a few functions that can be entered by the user. Let's say I have a function to convert a string to upper-case with the function <code>$upper(string)</code> and a function <code>$lower(string)</code>. The user can enter those in a text box while using placeholders to insert content (e.g. %T for the title of a song). Using both placeholders and functions, the user can enter a complete naming pattern. </p>
  
  <p>Functions can be nested and I want to execute the inner-most function first. Now I am looking for a Regex to identify it. In english, I am looking for <code>a function (and its value) that does not contain another function.</code> </p>
  
  <p>During my tests, I use hyphens instead of brackets and no $-sign. This is a lot easier to read. So the functions during testing are <code>lower-sometext-</code>.</p>
  
  <p>This is my guess so far: </p>
  
  <pre><code>(lower|upper)-(?!((lower|upper)-.*-))-
  </code></pre>
  
  <p>I read it as follows:</p>
  
  <ul>
  <li>find the word <code>upper</code> or <code>lower</code>, </li>
  <li>followed by a hyphen, </li>
  <li>followed by anything that is NOT the word <code>upper</code> or <code>lower</code>, a hyphen, a random number of random characters and a hyphen</li>
  <li>followed by a hypen.</li>
  </ul>
  
  <p>But that won't even accept <code>lower-sometext-</code>. I am trying different things for more than 2 hours but I can't figure it out...</p>