title: Regex to detect all characters outside of the <img> tag
body: <p>I don't have experience in regex. I am just trying to find a way to detect 
  and delete every character outside of the img tag. In other words I want to 
  strip a given html code from all text and tags and just keep everything within 
  the img tags. The result should show just the image tags like that: </p>
  
  <pre><code>&lt;img src="sourcehere"&gt; 
  </code></pre>
  
  <p>Is there a way to do this?</p>
  
  <p>UPDATE:
  I need specifically a regex that goes in preg_replace.
  This is what I have done, but it doesn't work:</p>
  
  <pre><code>$buffer ="&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;img src='image.jpg'&gt;&lt;/body&gt;&lt;/html&gt;";
  
  $buffer = preg_replace('(?i)&lt;(?!img|/img).*?&gt;', '', $buffer);
  echo $buffer; /* should output &lt;img src='image.jpg'&gt; but it doesn't */
  </code></pre>