Restrict Characters using regex matches in java -


basically have java string want restrict characters other regex code

string ucharset = "^[a-za-z0-9-~!@#().]+"; if("hello.hi".matches(ucharset)){         unotallowedcharec = "0x00000030"; } 

now problem if statement gets execute although have regex allow . appreciate if tell me doing wrong.

okay figured solution thought other facing same problem. first create boolean equal "hi+hello".matches(ucharset) , needed create if statement , see if returned true or false:

boolean umorn = "hi+hello".matches(ucharset); if(umorn != true)     unotallowedcharec = "0x00000030"; 

Comments