Reputation: 268
for(String paramName:paramNames){
String regexString = regexPair.get(paramName);
try{
System.out.println(regexString);
Pattern p = Pattern.compile(regexString);
Matcher m = p.matcher(paramMap.get(paramName)[0]);
status = m.matches();
}catch(Exception e)
{
e.printStackTrace();
}
if(!status)
break;
}
where regexSring
have value
"^(?!.*[^A-Za-z0-9@])((?=.*\\d)(?=.*[a-z]).{6,20})$"
The value of regexString
is fecthed from mysql db an populated in map and paramMap.get(paramName)[0]
have value "dssf55454"
but it is retuning false while it should return true.
If I write the following sample program
Pattern p = Pattern.compile("^(?!.*[^A-Za-z0-9@])((?=.*\\d)(?=.*[a-z]).{6,20})$");
Matcher m = p.matcher("mal4554SD");
status = m.matches();
System.out.println(status);
it returns true. Why?
Upvotes: 1
Views: 77
Reputation: 819
The problem might be in the snippet \\d
in the regexString
.
What is the result printed in console?
System.out.println(regexString);
Also, it will be helpful if you can share more details about regexPair
and its get()
.
Upvotes: 3