title: Matching regex groups within groups if they exist in javascript
body: <p>I have these couple lines that I would like to match and right now I use multiple regexes to match them all, however I'm wondering if it is possible to match both in one regex:</p>
  
  <pre><code>@@Author:logan
  //and these, three variations
  @@tags:markdown,github,repetitivetag, tagwithsubtags:subtag, another:subtag:subtag2:repeating:this:repeating,repetitivetag,repetitivetag:withsubby,repetitivetag:withsubtag
  @@tags:markdown;github;repetitivetag;tagwithsubtags:subtag,another:subtag:subtag2:repeating:this:repeating;repetitivetag;repetitivetag:withsubby;repetitivetag:withsubtag
  @@tags:markdown;git-hub;repetitive-tag;tag_with_sub-tags:sub_tag,another:sub_tag:sub-tag2:repeating:this:repeat-_-_-ing;repetitive-tag;repetitive_tag:with_subby;repetitive_tag:with_subtag
  </code></pre>
  
  <p>What I do first is to match the <code>@@NAME:VALUE</code> part:</p>
  
  <ul>
  <li><code>/^(?:@@)(\w+):(.*.)(?:\n+|$)/gm</code></li>
  </ul>
  
  <p>let's say the first group is <code>NAME</code> and second group is <code>VALUE</code>.</p>
  
  <p>If <code>NAME</code> is <code>tags</code> then I match the following regex in <code>VALUE</code>:</p>
  
  <ul>
  <li><code>/(\w+)((?=,|;)|(:\w[\w|\-]+\w){0,}|)/g</code></li>
  </ul>
  
  <p>This matches several groups that are like <code>TAG;TAG;TAG ...</code> or <code>TAG,TAG,TAG ...</code> in <code>VALUE</code> that we matched before</p>
  
  <p>Then I match each <code>TAG</code> with this to get the <code>SUBTAG</code></p>
  
  <ul>
  <li><code>/(:)(\w[\w|\-]+\w)(?=:|)/g</code></li>
  </ul>
  
  <p>Now that matches groups like <code>:SUBTAG:SUBTAG:SUBTAG ...</code> within <code>TAG</code> that we matched above</p>
  
  <h1>In Summary</h1>
  
  <p>I want to match </p>
  
  <ul>
  <li><code>(@@)(NAME)(:)(VALUE)</code>
  <ul>
  <li><code>(TAG)(;)(TAG)(;)(TAG) ...</code> in VALUE
  <ul>
  <li><code>(:)(SUBTAG)(:)(SUBTAG))(;)</code> in tag</li>
  </ul></li>
  </ul></li>
  </ul>
  
  <h2>example</h2>
  
  <ol>
  <li><p><code>@@Author:logan</code> should be able to get <code>Name = Author</code>, <code>Value = logan</code></p></li>
  <li><p>if value is multiple, like if its seperated by comma or semi-colon then matching something like <code>@@tags:tag1;tag2</code> should be able to get</p>
  
  <p><code>Name = Tags</code>, `Value = ['tag1','tag2']</p></li>
  <li><p>if value has a subvalue such as </p>
  
  <p><code>@@Author:logan:lastname</code> </p>
  
  <p>or this as its intended purpose </p>
  
  <p><code>@@Tags:tag1:subtag;tag2:subtag1:subtag2</code> should be able to get:</p>
  
  <p><code>Name = Author</code>, <code>Value = [{logan : [lastname]}]</code> and </p>
  
  <p><code>Name = Tags</code>, <code>Value = [{tag1 : [subtag]}, {tag2 : [subtag1, subtag2]}]</code></p></li>
  </ol>
  
  <p>How can I match groups within groups and only if they exist?</p>