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);
		
	}
}

猜你喜欢

转载自tomhat.iteye.com/blog/2268688