samedi 18 avril 2015

Regex to find any characters failing

I keep getting nullpointerexception for this code.


Just want to determine if string has any characters A-Z and return false, else return true. What am I doing wrong?


Note data = "A2"



public static boolean calculable(String data) {
Pattern p = Pattern.compile("[A-Z]");
Matcher m = p.matcher(data);
if (m.find()) {

return false;
}

return true;
}

Aucun commentaire:

Enregistrer un commentaire