title: Regex Capturing Group with alternative doesn't match
body: <p>I have the following string where I want to match the valid <code>&lt;key&gt;:&lt;value&gt;</code> pairs.</p>
  <p>A valid <code>&lt;key&gt;</code> is anything with a non-whitespace character followed by <code>:</code><br />
  A valid <code>&lt;value&gt;</code> is either enclosed in <code>[]</code> or a string without whitespaces.</p>
  <pre class="lang-none prettyprint-override"><code>key1:value1 key#2:@value#2 nyet key3:[@value#3, value4] key4:[value5] :bar
  </code></pre>
  <p>Basically I want to match everything except <code>nyet</code> and <code>:bar</code></p>
  <p>I came up with following regex <code>\S+:(\S+|\[[^]]+\])</code> but it doesn't seem to match the expression in <code>key3:[@value#3, value4]</code>. In the capturing group, the second alternative <code>\[[^]]+\]</code> should match this expression, so I don't understand why it doesn't match.</p>
  <p>The following regex works: <code>\S+:([^([ )]+|\[[^\]]+\])</code> but doesn't feel elegant.</p>
  <p>Questions:</p>
  <ol>
  <li>Why does the first regex <code>\S+:(\S+|\[[^]]+\])</code> not work?</li>
  <li>How would a more elegant solution look to match the key value pairs?</li>
  </ol>