Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java util regex patternsyntaxexception unclosed character class near index

2648423Oct 5 2015 — edited Oct 5 2015

Hello,

i put the below on an input text in my page :

^[A-Z a-z\u0600-\u06FF][^@/\\]{8,19}

but an error shown is that

java util regex patternsyntaxexception unclosed character class near index 33

i tried to do it in java like :

    public void myValidator(FacesContext facesContext,UIComponent uIComponent, Object object) {

        if(object!=null){

                  String name=object.toString();

                  String expression="^[A-Z a-zu0600-u06FF][^@/\\]{8,19}";

                  CharSequence inputStr=name;

                  Pattern pattern=Pattern.compile(expression.replaceAll("[\\[\\]]", ""));

                  Matcher matcher=pattern.matcher(inputStr);

                  String msg="New Password is not in Proper Format";

                  if(matcher.matches()){

                    

                  }

                  else{

                      throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,msg,null));

                  }

              }

    }

but it is not the syntax that i want,it always prints

New Password is not in Proper Format

how can i do it please.

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 2 2015
Added on Oct 5 2015
2 comments
3,127 views