title: Counting Words from a String
body: <p>I'm supposed to create a method that count the number of words in the sentence that meet or exceed int minLength. For instance, if the minimum length given is 4, your program should only count words that are at least 4 letters long.</p>
  
  <p>The words can will separated by one or more spaces. Non-letter characters (spaces, punctuation, digits, etc.) may be present, but they don't count towards the length of the word.</p>
  
  <pre><code>    public static int countWords(String original, int minLength) {
      original = original.replaceAll("[^A-Za-z\\s]", "").replaceAll("[0-9]", "");
      String[] words = original.split("\\s+");
  
  
      for(String word : words){ System.out.println(word); }
  
      int count = 0;
      for (int i = 0; i &lt; words.length; i++) {
          if (words[i].length() &gt;= minLength) {
              count++;
          } else if (words[i].length() &lt; minLength || minLength == 0) {
              count = 0;
          }
      }
      System.out.println("Number of words in sentence: " + count);
      return count;
  }
  </code></pre>
  
  <p>Okay so I changed my code, but the counter is now off by one. Say I input the following : Spain is a beautiful country; the beache's are warm, sandy and spotlessly clean."</p>
  
  <p>The output I receive is...
  Spain
  is
  a
  beautiful
  country
  the
  beaches
  are
  warm
  sandy
  and
  spotlessly
  clean
  Number of words in sentence: 10</p>
  
  <p>The number of word is off by one, it should be 11. Looks like it's not counting the last word in the sentence. I'm not sure where the issue stems from considering I only changed the replaceAll to include an escape character. </p>