title: Matching optional parameters with non-capturing groups in Bash regular expression
body: <p>I want to parse strings similar to the following into separate variables using regular expressions from within Bash:</p>
  
  <pre><code>Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";attributes="occi.core.id occi.core.title";
  </code></pre>
  
  <p>or</p>
  
  <pre><code>Category: resource;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Resource";rel="http://schemas.ogf.org/occi/core#entity";attributes="occi.core.summary";
  </code></pre>
  
  <p>The first part before "title" is common to all strings, the parts title and attributes are optional.</p>
  
  <p>I managed to extract the mandatory parameters common to all strings, but I have trouble with optional parameters not necessarily present for all strings. As far as I found out, Bash doesn't support Non-capturing parentheses which I would use for this purpose.</p>
  
  <p>Here is what I achieved thus far:</p>
  
  <pre><code>CATEGORY_REGEX='Category:\s*([^;]*);scheme="([^"]*)";class="([^"]*)";'
  category_string='Category: entity;scheme="http://schemas.ogf.org/occi/core#";class="kind";title="Entity";attributes="occi.core.id occi.core.title";'
  [[ $category_string =~ $CATEGORY_REGEX ]]
  echo ${BASH_REMATCH[0]}
  echo ${BASH_REMATCH[1]}
  echo ${BASH_REMATCH[2]}
  echo ${BASH_REMATCH[3]}
  </code></pre>
  
  <p>The regular expression I would like to use (and which is working for me in Ruby) would be:</p>
  
  <pre><code>CATEGORY_REGEX='Category:\s*([^;]*);\s*scheme="([^"]*)";\s*class="([^"]*)";\s*(?:title="([^"]*)";)?\s*(?:rel="([^"]*)";)?\s*(?:location="([^"]*)";)?\s*(?:attributes="([^"]*)";)?\s*(?:actions="([^"]*)";)?'
  </code></pre>
  
  <p>Is there any other solution to parse the string with command line tools without having to fall back on perl, python or ruby?</p>