Thursday, July 3, 2014

Pattern matches in java








hi i have code which validate code enter by user








the requirement say the maxlength=2 and minlength=1 and is a string








the user can enter code as follows








00








A1








HH








12








10








09








I have this code












Java Code:











public boolean isValidPattern(String s_value, String s_pattern)

{

boolean flag = false;



if (Pattern.matches(s_pattern, s_value))

{

flag = true;

}



return flag;

}



if (!isValidPattern(code, "[0-9X]{1,2}"))

{



if(!isValidPattern(code, "[A-Z]{1,2}"))



{

System.out.println("wrong patten code ");

}









my problem is when user put








A1 AM geting error















No comments:

Post a Comment