title: Regex Multiple Capture of Group
body: <p>I'm using regex to capture the dimensions of ads</p>
  
  <p>Source content is an HTML File, and I'm trying to capture for content that looks like:  </p>
  
  <pre><code>size[200x400,300x1200] (could be 1-4 different sizes)
  </code></pre>
  
  <p>I'm trying to an array with the different sizes in it</p>
  
  <p>My capture code looks like this:</p>
  
  <pre><code>$size_declaration = array();
  $sizes = array();
  $declaration_pattern = "/size\[(\d{2,4}x\d{2,4}|\d{2,4}x\d{2,4},){1,4}\]/";
  $sizes_pattern = "/\d{2,4}x\d{2,4}/";
  
  $result = preg_match($declaration_pattern, $html, $size_declaration);
  if( $result ) {
      $result = preg_match_all($sizes_pattern, $size_declaration[0], $sizes);
      var_dump($sizes);
  }
  </code></pre>
  
  <p>The code above produces usable results:</p>
  
  <pre><code>$sizes = array(
    [0] =&gt; array (
      [0] =&gt; '200x400',
      [1] =&gt; '300x1200'
    )
  )
  </code></pre>
  
  <p>but it takes quite a bit of code. I was thinking it was possible to collect the results with a single regex, but I couldn't find a result that works. Is there a way to clean this up a bit?</p>