This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Basically what I want to do is to take a string, and see if there's a single non-letter character return a boolean value.
But I'm only getting a false when all chars are non-letter. Should I be iterating the String in a loop and doing a comparison of the chars, or is there a way to do it with the regexp and I'm just not seeing how to do it?
To match a character that is not in a set of characters, you can use the ^ symbol (a circumflex accent) to mean 'not'. So [^A-Za-z] means find a character that is not an A-Z. You could also do [^A-Z] and set the case insensitive flag:
Pattern p = Pattern.compile("[^A-Z]", Pattern.CASE_INSENSITIVE);
That should work for what you want to do. Keep in mind this will only work on basic English letters. Letters from other languages, including accented letters will match the above pattern and be seen as a non-letter. Accented Characters are seen in English some times such as the word R�sum�.