title: Parsing Custom JavaScript Annotations
body: <p>Implementing a large JavaScript application with a lot of scripts, its become necessary to put together a build script. JavaScript labels being ubiquitous, I've decided to use them as annotations for a custom script collator. So far, I'm just employing the use statement, like this:</p>
  
  <pre><code>use: com.example.Class;
  </code></pre>
  
  <p>However, I want to support an 'optional quotes' syntax, so the following would be parsed correctly as well</p>
  
  <pre><code>use: 'com.example.Class';
  </code></pre>
  
  <p>I'm currently using this pattern to parse the first form:</p>
  
  <pre><code>/\s*use:\s*(\S+);\s*/g
  </code></pre>
  
  <p>The '\S+' gloms all characters between the annotation name declaration and the terminating semi colon. What rule can I write to substitute for \S+ that will return an annotation value without quotes, no matter if it was quoted or not to begin with? I can do it in two steps, but I want to do it in one.</p>
  
  <p>Thanks- I know I've put this a little awkwardly</p>
  
  <p><strong>Edit 1.</strong></p>
  
  <p>I've been able to use this, but IMHO its a mess- any more elegant solutions? (By the way, this one will parse ALL label names)</p>
  
  <pre><code>/\s*([a-z]+):\s*(?:['])([a-zA-Z0-9_.]+)(?:['])|([a-zA-Z0-9_.]+);/g
  </code></pre>
  
  <p><strong>Edit 2.</strong></p>
  
  <p>The logic is the same, but expresses a little more succinctly. However, it poses a problem as it seems to pull in all sorts of javascript code as well.</p>
  
  <pre><code>/\s*([a-z]+):\s*'([\w_\.]+)'|([\w_\.]+);/g
  </code></pre>