title: Getting a substring in Ruby by x number of chars
body: <p>I'm trying to produce some Ruby code that will take a string and return a new one, with a number x number of characters removed from its end - these can be actual letters, numbers, spaces etc.</p>
  
  <p>Ex: given the following string</p>
  
  <p><code> a_string = "a1wer4zx" </code></p>
  
  <p>I need a simple way to get the same string, minus - say - the 3 last characters. In the case above, that would be "a1wer". The way I'm doing it right now seems very convoluted:</p>
  
  <pre><code>an_array = a_string.split(//,(a_string.length-2))
  an_array.pop
  new_string = an_array.join
  </code></pre>
  
  <p>Any ideas?</p>