title: Preg_replace to replace dynamic Image URL
body: <p>I am trying to replace an Image URL which changes constantly. </p>
  
  <p>Image URL: <code>src="/images/previews/logo-15-hp.jpg"</code>. In this URL logo-15-hp.jpg will be changing every day to something else. What I am trying to do is replace this URL to a default one like this: <code>src="http://mywebsite.com/images/previews/default.jpg"</code>. </p>
  
  <p>I tried doing this with preg_replace, but I am unable to make it work. I tried different variations and finally gave up. I would be glad if someone could help me with this. </p>
  
  <p>My Code: </p>
  
  <pre><code>$content = 
  preg_replace('src="/images/previews/logo\-15\-hp\.jpg"','src="http://mywebsite.com/default.gif"',$content);
  </code></pre>
  
  <p>I also tried this: </p>
  
  <pre><code>preg_replace('src\=\"\/images\/previews\/logo\-15\-hp\.jpg\"','src="http://mywebsite.com/default.gif"',$content);
  </code></pre>
  
  <p>Also please explain any code you suggest. It will help me in future. </p>
  
  <p>Thanks!</p>
  
  <p>Edit: I am trying to automatically detect the URL and change, but I can't even do it with full URL in preg_replace. For instance I need a code like this: </p>
  
  <p>$content = preg_replace('src="/images/previews/logos**<strong>*This Part Changes constantly, so I need preg_replace instead of str_replace***</strong>.jpg"','src="http://mywebsite.com/default.gif"',$content);</p>