title: How to remove the last empty keys in a string
body: <p>I have a string that looks like this:</p>
  <pre><code>&quot;a               &quot;
  </code></pre>
  <p>As you can see there is only one character that is not empty &quot; &quot;. How do I remove the last charaters of the string so only the valid one(s) will remain:</p>
  <pre><code>&quot;a&quot;
  </code></pre>
  <p>This can also be considered in cases where the first characters are empty:</p>
  <pre><code>&quot;         a&quot;
  </code></pre>
  <p>I cannot simply remove each empty key as they can be part of a more complex sentence like this:</p>
  <pre><code>&quot;I love Js            &quot;
  </code></pre>