测试不包含某字符串
1、html 实现
<script>
function aa(str){
?var patten = /^((?!contextPath)\w)*$/;
?if(patten.test(str.value)){
??alert("不包含");
?}else{
??alert("包含");}
}
</script>
?<body>
<input? type="text" name="s" value="" onblur="aa(this)">
?</body>
?
?2、java 实现
System.out.println("请输一个字符串");
??Scanner input = new Scanner(System.in);
??String str=input.nextLine();;
??String s = "^.*[^contextPath].*$";
??Pattern p=Pattern.compile(s);
??Matcher m=p.matcher(str);
??if(m.matches()){
???System.out.print("不包含");
??}else
???System.out.print("包含");
???
??}