title: Replace all images (with src/url tag) with data:image
body: <p>I must save html source code in a sql database (for an android app). The content must stored local. So images must also saved. I think it would be appropriate to proceed following:</p>
  
  <ul>
  <li>on the server (php): replace all img src with img src="data:image..." strings (regex and load image?)</li>
  <li>then I could store the html code local in my appliction</li>
  </ul>
  
  <p>But how could I realize this? Or should I save the images with html5? I hope you could help me!</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>$search = '(&lt;img.*?src=")([^"]*?(\/[^/]*\.[^"]+))';
  $replace = "&lt;img src=\"".data_uri('$2')."\"&gt;";
  $content = preg_replace($search, $replace, $content);
  </code></pre>
  
  <p>Could someone correct this code? Thanks!</p>
  
  <p><strong>2nd UPDATE:</strong></p>
  
  <p>Examples:</p>
  
  <pre><code>&lt;img class="alignnone" src="https://lh4.googleuserco (...)
  &lt;img src="https://lh4.googleuserco (...)
  &lt;img width="400" height="100" src='...' (...)
  </code></pre>