String regEx = "listCategoryInfo.do?categoryId=.*";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher("listCategoryInfo.do?categoryId=5");
System.out.println(m.find() ); 为什么输出是false?
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher("listCategoryInfo.do?categoryId=5");
System.out.println(m.find() ); 为什么输出是false?
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher("listCategoryInfo.do\\?categoryId=5");依然是false
这里不需要转义,这里是普通字符串String regEx = "listCategoryInfo.do\\?categoryId=.*";
Pattern p = Pattern.compile(regEx);这里是正则表达式,需要转义