Adding Verification length()
ref ( ""), . , 0 ( 1, 2, 3...). if length, -
if (ref.length() > 5) {
for (int i = 0; i < 6; i++) {
if (ref.charAt(i) == '\0') {
problem = true;
}
}
} else {
System.out.println("Please enter at least 6 characters");
}
( ) Pattern (2 , 3 , b n). - ,
String ref;
Pattern p = Pattern.compile("([a-zA-Z]{2})(\\d{3})([B|N|b|n])");
Matcher m = p.matcher(ref);
if (m.matches()) {
System.out.println("ref is valid");
} else {
System.out.println("ref is not valid");
}