I want that my string didn't contain *,; and $. I use this code
private static boolean IsMatch(String s, String pattern) {
try {
Pattern patt = Pattern.compile(pattern);
Matcher matcher = patt.matcher(s);
return matcher.matches();
} catch (RuntimeException e) {
return false;
}
}
String regex ="[^*;$]";
System.out.println(IsMatch(url,regex));
But this method return always false. Can any one tell me what's the problem