title: Regex: match last and second-last character
body: <p>I need to wrap the two last characters in a string in a separate <code>&lt;span&gt;</code>:</p>
  
  <pre><code>-1:23 // This is what I have
  -1:&lt;span&gt;2&lt;/span&gt;&lt;span&gt;3&lt;/span&gt; // This is what I want
  </code></pre>
  
  <p>The following matches the last character – but how can I make it match the second last as well? </p>
  
  <pre><code>str.replace(/(.$)/, "&lt;span&gt;$1&lt;/span&gt;");
  </code></pre>
  
  <p>Thanks :) </p>