title: Regex to extract images from HTML - how to get only JPGs?
body: <p>I am using this PHP function to grab all <code>&lt;img&gt;</code> tags within any given HTML.</p>
  
  <pre><code>function extract_images($content)
  {
      $img    = strip_tags(html_entity_decode($content),'&lt;img&gt;');
      $regex  = '~src="[^"]*"~';    
  
      preg_match_all($regex, $img, $all_images);
  
      return $all_images;
  }
  </code></pre>
  
  <p>This works and returns <strong><em>all</em></strong> images (gif, png, jpg, etc).</p>
  
  <p>Anyone know how to change the regex...</p>
  
  <pre><code>~src="[^"]*"~
  </code></pre>
  
  <p>in order to only get files with <strong>JPG or JPEG</strong> extension?</p>
  
  <p>Thanks a bunch.</p>