title: Regex to replace domain of url if it's ending with .css
body: <p>I'm trying to write a php script to replace ONLY domain of every URL in the content with new domain if the URL ends with <code>.css</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>www.example.com/asset/css/style.css
  </code></pre>
  
  <p>After checking condition and replacement we have:</p>
  
  <pre><code>www.new-domain.net/asset/css/style.css
  </code></pre>
  
  <p>Would anyone please help me to find the correct pattern for this.</p>
  
  <p>So far I've tried this:</p>
  
  <pre><code>preg_replace('/[http://].*\.(css)/i','www.new-domain.net',$Html_contents)
  </code></pre>