title: How would I make sure that a string such as "John " does not replace "John"?
body: <p>I'm working on a Registration UI and it checks if the user already exists in the database, the program works fine and all, but i have received bug reports that if you add whitespace at the start or end of the name you entered, it will assume its a new name and won't be blocked by detecting that the name already exists.</p>
  
  <pre><code>String name = txfUName.getText();
  
  If(this.checkIfNameExists(name) == true);
  {
  
  ...
  
  }
  else
  {
  
  ...
  
  }
  </code></pre>
  
  <p>How would I check if the first and last character is a whitespace (in a loop)
  and replace that whitespace with an empty string "" until there are no whitespaces in front or at the back of the name, assume the name can contain whitespaces in between words.</p>