title: extract attributes from a WordPress like shortcode
body: <p>I have a string like WordPress shortcodes and need to extract the attributes. :
  <br/><code>[prefix action="foo" class="bar"][/prefix]</code><br/><br/>
  I need to keep exactly this structure that means I can't i.e. remove quotes to become <code>action=foo</code><br/><br/></p>
  
  <p>right now i used WordPress regex patterns:</p>
  
  <pre><code>// Grabs [prefix foo="bar"][/prefix] from the $content
  $pattern = '/\[(\[?)(' . PREFIX . ')(?![\w-])([^\]\/]*(?:\/(?!\])[^\]\/]*)*?)(?:(\/)\]|\](?:([^\[]*+(?:\[(?!\/\2\])[^\[]*+)*+)\[\/\2\])?)(\]?)/';
  preg_match_all($pattern, $content, $matches, PREG_SET_ORDER);
  </code></pre>
  
  <p>this is the result:</p>
  
  <pre><code>Array
   (
       [0] =&gt; [prefix action="foo" class="bar"][/prefix]
       [1] =&gt; 
       [2] =&gt; prefix
       [3] =&gt;  action="foo" class="bar"
       [4] =&gt; 
       [5] =&gt; 
       [6] =&gt; 
   )
  </code></pre>
  
  <p>Then I Loop through regex matches</p>
  
  <pre><code>foreach( $matches as $block )
      {
      /*
       * I'm not working on WordPress platform, 
       * But I used function shortcode_parse_atts
       */
      $attr = shortcode_parse_atts( $block[3] );
  </code></pre>
  
  <p>results:</p>
  
  <pre><code>Array
  (
      [action] =&gt; "foo"
      [class] =&gt; "bar"
  )
  </code></pre>
  
  <p>and in the end <code>extract($attr)</code>. but as you can see <code>$class</code> and <code>$action</code> values are between double quotes. so i need to get ride of those quotes.
  <br/><br/>
  <strong>In short:</strong> <br/>
  I want <code>$class = "bar"</code> becomes <code>$class = bar</code>
  <br/>
  <br/>
  In case you think why i don't use <code>str_replace</code> or <code>preg_replace</code>, I did but it did not removed quotes somehow ( which i don't understand why )</p>