title: How can I truncate a string and remove a trailing character if present?
body: <p>I have a variable:</p>
  
  <pre><code>a = "test data";
  a = "test data!";
  </code></pre>
  
  <p>How can I remove the '!' if it exists at the end of the string? If possible I am looking for a method that would be the most clean solution.</p>