java验证是否包含特殊字符/\:*?"


public class MatchTest {

private static final String REGEX = "^.*[(/) | (\\\\) | (:) | (\\*) | (\\?) | (\") | (<) | (>)].*$";

public static void main(String[] args) {
String s = "aswd?qwe:f";
System.out.println(isMatches(s, REGEX));

}

public static boolean isMatches(String str,String regex){
return str.matches(regex);

}
}

你可能感兴趣的:(java,matches)