mongo的查询某字段不为0
// 查询差异不为0的数据
Pattern compile = Pattern.compile("^[0.]*$");
// mongo的查询
Criteria criteria = new Criteria();
criteria.and("qtyStuDiff").not().regex(compile);
正则表达式匹配为0
public static void main(String[] args) {
String str = "0.000";
String pattern = "^[0.]*$";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str);
System.out.println(m.matches()); // true
}
标签:匹配,String,Pattern,0.00,查询,compile,正则,Criteria,mongo
From: https://www.cnblogs.com/alpari-wang/p/17445901.html