Basically my question is this, why is:
String word = "unauthenticated";
word.matches("[a-z]");
returning false? (Developed in java1.6)
Basically I want to see if a string passed to me has alpha chars in it.
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.
The
String.matches()function matches your regular expression against the whole string (as if your regex had^at the start and$at the end). If you want to search for a regular expression somewhere within a string, useMatcher.find().The correct method depends on what you want to do:
String.matches()with[a-z]+)Matcher.find()with[a-z])