title: How can I remove punctuation from input text in Java?
body: <p>I am trying to get a sentence using input from the user in Java, and i need to make it lowercase and remove all punctuation. Here is my code:</p>
  
  <pre><code>    String[] words = instring.split("\\s+");
      for (int i = 0; i &lt; words.length; i++) {
          words[i] = words[i].toLowerCase();
      }
      String[] wordsout = new String[50];
      Arrays.fill(wordsout,"");
      int e = 0;
      for (int i = 0; i &lt; words.length; i++) {
          if (words[i] != "") {
              wordsout[e] = words[e];
              wordsout[e] = wordsout[e].replaceAll(" ", "");
              e++;
          }
      }
      return wordsout;
  </code></pre>
  
  <p>I cant seem to find any way to remove all non-letter characters. I have tried using regexes and iterators with no luck. Thanks for any help.</p>