import java.util.regex.*; import java.util.*; class WordInput2 { public static void main(String[] args) { Scanner userin = new Scanner(System.in); Pattern isWord = Pattern.compile("[A-Za-z]+"); Matcher m; String word; System.out.println("Enter some words ('done' to stop):"); do { word = userin.next(); m = isWord.matcher(word); if ( m.matches() ) { System.out.printf("That word has %d letters.\n", word.length()); } else { System.out.println("That wasn't a word."); } } while( !word.equals("done") ); } }