title: Combining two preg_replace into one
body: <p>I want to combine those 2 preg_replace into a single one.For example replace every <code>data-thumb-bg="</code> with <code>style="background-image: url('</code> and <strong>after that</strong> if there is <code>.jpg</code> replace it with <code>.jpg);</code>.</p>
  
  <pre><code> $input = preg_replace('#data-thumb-bg="#s', 'style="background-image: url(', $input);
   $input = preg_replace('#.jpg#s', '.jpg);', $input); //this must be executed only if a match has been found for above
  </code></pre>
  
  <p>How can i do that ?</p>
  
  <p><strong>Edit</strong> </p>
  
  <p>I think i have wrongly expressed myself </p>
  
  <p>The <code>.jpg</code> should be replaced <strong>only if</strong> <code>data-thumb-bg=</code> has been replaced.Like first you replace the <code>data-thumb-bg</code> then  you replace the <code>.jpg</code> that follow the <code>data-thumb-bg</code></p>
  
  <p>Kind Regards</p>