title: Is there a way to replace a range of characters in a string using gsub?
body: <p>I would like to replace every character except the last 4 with a "#"...like you would see on a credit card statement. I have accomplished this using the Array#each method to iterate through indexes [0..-4] and then another for [-4..-1] and shoveling results from both into a new string. I'm thinking that maybe this could be better done with regex? But I am new to regex, and google hasn't turned up anything I can use in regards to replacing an entire range without losing the length of the string. I have tried </p>
  
  <pre><code>str.gsub(str[0..-5],'#')
  </code></pre>
  
  <p>(and a few other things) but it replaces the entire range with a single character. How can I accomplish my goal using regex?</p>