title: Delete whitespaces in the beginning of each line and end the end of the each line
body: <p>I have a string like this : </p>
  
  <pre><code>Mr Moh Jo\n
  Address\n
   33333 City\n\n
  Aland Islands
  </code></pre>
  
  <p>and I would like to delete whitespaces in the beginning of each line and end the end of the each line with following code but it didn't work </p>
  
  <pre><code>    public static String trimWhiteSpaceFromTheBeginingAndEndOFTheLine(
          String string) {
      Pattern trimmer = Pattern.compile("^\\s+|\\s+$");
      Matcher m = trimmer.matcher(string);
      StringBuffer out = new StringBuffer();
      while (m.find())
          m.appendReplacement(out, "");
      m.appendTail(out);
  
      return out.toString();
  }
  </code></pre>
  
  <p>Expected result: </p>
  
  <pre><code>Mr Moh Jo\n
  Address\n
  33333 City\n\n
  Aland Islands
  </code></pre>