java mongodb 包含与不包含 的 模糊查询

来源:互联网 发布:冲压模具报价软件 编辑:程序博客网 时间:2024/05/21 12:08

//模糊查询包含,与不包含,主要就是那两个正则的写法,直接拷过去,一个空格都不能少!!!

if (queryFlag != null && queryFlag != "") {

if(queryFlag.equals("content")){
if (content != null && content != "") {
Pattern compile = Pattern.compile( content, Pattern.CASE_INSENSITIVE);
composeCod.put("COMTENT", compile);
}
}
if (queryFlag.equals("includeContent")) {

if (content != null && content != "") {

//模拟包含查询

Pattern compile = Pattern.compile("^.*" + content+ ".*$", Pattern.CASE_INSENSITIVE);
composeCod.put("COMTENT", compile);
}
}
if (queryFlag.equals("notIncludeContent")) {
String a = "a";

if (content != null && content != "") {

//模糊不包含查询

Pattern compile = Pattern.compile("^((?!" + content+ ").)*$", Pattern.CASE_INSENSITIVE);
composeCod.put("COMTENT", compile);
}
}
}
0 0
原创粉丝点击