java正则表达式
东方柏 2015-04-11 05:00:05 请大家帮忙看看:
public static void test00(){
String str = "Windows3.1";
String regex = "Windows(?!95|98|NT|2000)";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(str);
System.err.println(m.matches());
}
打印的结果是false,但是按照java正则表达式语法这个结果不应该是true吗
这是我查的语法:
(?!pattern):正向否定预查,在任何不匹配pattern的字符串开始处匹配查找字符串。这是一个非获取匹配,也就是说,该匹配不需要获取供以后使用。例如“Windows(?!95|98|NT|2000)”能匹配“Windows3.1”中的“Windows”,但不能匹配“Windows2000”中的“Windows”。
这个是什么问题呢