I need a method that can tell me if a String has non alphanumeric characters.
For example if the String is “abcdef?” or “abcdefà”, the method must return true.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using Apache Commons Lang:
Alternativly iterate over String’s characters and check with:
You’ve still one problem left:
Your example string “abcdefà” is alphanumeric, since
àis a letter. But I think you want it to be considered non-alphanumeric, right?!So you may want to use regular expression instead: