title: PHP regex matches timestamp but not when part of script tag
body: <p>I have a regex pattern that is close to working but I'm still missing something. I want to swap out only the timestamp of a <code>&lt;script&gt;</code> tag's <code>src</code>:</p>
  
  <p>So I want this:</p>
  
  <pre><code>stuff BEFORE...&lt;script src='/assets/mySite-1238459846.js'&gt;&lt;/script&gt;
  stuff AFTER...
  </code></pre>
  
  <p>to be this:</p>
  
  <pre><code>stuff BEFORE...&lt;script src='/assets/mySite-0123456789.js'&gt;&lt;/script&gt;
  stuff AFTER...
  </code></pre>
  
  <p>Here's the code which switches the timestamp but only when with <code>src</code> doesn't contain any special characters or slashes, meaning only <code>$stringNotSpecial</code> works:</p>
  
  <pre><code>$stringNotSpecial='mySite-1238459846.js'; //Works!
  $stringSpecial='stuff BEFORE...&lt;script src='/assets/mySite-0123456789.js'&gt;&lt;/script&gt;
  stuff AFTER...'; //DOESNT work :(
  $timestamp='0123456789';
  $pattern = '/mySite-[0-9]+.js/';
  echo preg_replace($pattern, 'mySite-'.$timestamp.'.js', $stringNotSpecial);
  echo '&lt;br&gt;';
  echo echo preg_replace($pattern, 'mySite-'.$timestamp.'.js', $stringSpecial);
  </code></pre>