title: How to replace all characters except the last digits
body: <p>I'm trying to replace the <code>-r</code> in this Semantic version <code>2020.7.28-r5</code> with a single period, but I'm getting this instead <code>2020.7.28.</code>.</p>
  <p>Here's what I've come up with so far:</p>
  <pre><code>&quot;2020.7.28-r5&quot; -replace &quot;(-[A-Za-z-][0-9A-Za-z-]*)&quot;, &quot;.&quot;
  </code></pre>
  <p>A specification:</p>
  <ul>
  <li><code>r</code> will always be one or more characters (in this case simply <code>r</code>)</li>
  <li><code>r</code> can be any SemVer-legal character (<code>[0-9A-Za-z-]</code>)</li>
  <li><code>r</code> will always end in a character, never a digit</li>
  <li><code>r</code> will always be preceded by a hyphen <code>-</code></li>
  <li>The final number (the build number for the day) will always be one or more digits</li>
  </ul>
  <p>Based on <a href="https://stackoverflow.com/a/35510028">this answer</a> I tried this expression:</p>
  <pre><code>&quot;(-[A-Za-z-][0-9A-Za-z-]*)(?=\d{4})&quot;
  </code></pre>
  <p>But it didn't replace anything.</p>
  <p>How can I start with <code>2020.7.28-The11thFantasticallyCleverUpdateForTheDay11</code> and end up with <code>2020.7.28.11</code>?</p>