title: Preg_replace URLs and images in PHP
body: <p>I have some string with text and I want to replace all image links to img tags and other links to a tags.</p>
  
  <p>I already did that:</p>
  
  <pre><code>$row['message'] = preg_replace('/(http:\\/\\/.+(png|jpeg|jpg|gif|bmp))/Ui', '&lt;img height="'.self::getConfig('image_height').'" src="$1" /&gt;', $row['message'], -1, $countImages);
  </code></pre>
  
  <p>How to replace all links except in img tags to a tag in <code>$row['message']</code>?</p>
  
  <p>Thanx!</p>