title: How to replace a word which has a specific pattern in text?
body: <p>I have a <code>ntext</code> (or <code>nvarchar(max)</code>) column which contains HTML text for <strong>example</strong>:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;P&gt;Hello &lt;IMG title="" border=0 alt="" src="files/1.JPG"&gt;&lt;/P&gt;
  &lt;P&gt;&amp;nbsp;&lt;/P&gt;
  &lt;P&gt;&lt;IMG title="" border=0 alt="" src="files/folder1/2.JPG"&gt;&lt;/P&gt;
  &lt;P&gt;&amp;nbsp;&lt;/P&gt; World!
  &lt;P&gt;&lt;IMG title="" border=0 alt="" src="files/folder2/files/3.JPG"&gt;&lt;/P&gt;
  &lt;P&gt;&amp;nbsp;&lt;/P&gt;
  &lt;P&gt;&lt;IMG title="" border=0 alt="" src="files/4.JPG"&gt;&lt;/P&gt;
  </code></pre>
  
  <p>Now I need to replace each path of the <code>src</code> from <code>files/</code> to <code>files/new/</code> (or to other path) but only those with path of <code>files/</code>.</p>
  
  <p>a <code>REPLACE</code> won't work (I think) because it would change also <code>files/folder1/</code> and <code>files/folder2/</code>.</p>
  
  <p>In the above example, I need to only change the path for <code>1.JPG</code> and <code>4.JPG</code>.</p>
  
  <p>How can I do it? <em>(The question is specific to sql-server)</em>.</p>
  
  <p>Note: The file names/content can vary. the above HTML is just an example.</p>