I am trying to loop through a string and check each character if one of the characters is a number. If it is a number, I want to return it as true. I have a string \"crash\"
Well you can use Integer.parseInt("string") and catch the exception.
Integer.parseInt("string")
try { int num = Integer.parseInt("string"); return true; } catch (NumberFormatException nfe) { return false; }
Or another way with regEx:
if ("string".replaceAll("\\d+","").length() > 0) { //false } else { //true }