how would i check a string for special characters such as $%#, and numbers? I only want chars, ex abcd.
the only method i can think of is to make an arraylist of the alphabet and check each index to see if it is in the arraylist.
thanks
how would i check a string for special characters such as $%#, and numbers? I only want chars, ex abcd.
the only method i can think of is to make an arraylist of the alphabet and check each index to see if it is in the arraylist.
thanks
RegEx is probably your best bet:
Pattern p = Pattern.compile("[a-zA-Z]");
Matcher m = p.matcher(sourceString);
boolean b = m.matches();
you can try a regex:
Pattern p = Pattern.compile("[^a-zA-Z]");
if(p.matcher(string).find()){
//something is not a letter
}