Only digits and dots and nothing else
Here is the requirement where the input is a String and our program should find whether it contains characters like a ,b (or) any special characters.
It can accept only digits and dots and nothing else and return a boolean result.
public static boolean questionnarieSpecific(String input){
Pattern p = Pattern.compile("[^\\d\\.]");
Matcher m = p.matcher(input);
boolean b = false;
boolean result = true;
while(b = m.find()) {
result= false;
break;
}
return result;
}
0 Comments:
Post a Comment
<< Home