public class samppatmatch {
private boolean validatingpswwithpattern(String password){
String math="[a-zA-z0-9]+[(]+(?:[^\\]+|\\.)*";
Pattern pswNamePtrn =Pattern.compile(math);
boolean flag=false;
Matcher mtch = pswNamePtrn.matcher(password);
if(mtch.matches()){
flag= true;
}
return flag;
}
public static void main(String args[]){
samppatmatch obj=new samppatmatch();
boolean b=obj.validatingpswwithpattern("");
System.out.println(b);
}
}
对于上述代码,我得到了这种类型的异常:
java.util.regex.PatternSyntaxException: Unclosed character class near index 28