当前位置:网站首页>Mongo Fuzzy query, with Special Characters need to escape, to Query
Mongo Fuzzy query, with Special Characters need to escape, to Query
2022-06-22 04:34:00 【12 singe de programme】
mongdb Requête floue,Il y a aussi des symboles spéciaux dans le contenu à récupérer,Cause Impossible de récupérer les données,Pour obtenir l'effet de détection,Oui. Détection de caractères spéciaux dans le contenu pour l'évasion,Pour obtenir un effet de récupération
Un.、échapper aux caractères spéciaux réguliers Méthodes
/** * échapper aux caractères spéciaux réguliers ($()*+.[]?\^{},|) * * @param keyword * @return */
public static String escapeExprSpecialWord(String keyword) {
String[] fbsArr = {
"\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|" };
for (String key : fbsArr) {
if (keyword.contains(key)) {
keyword = keyword.replace(key, "\\" + key);
}
}
return keyword;
}
2.、Application
Criteria criteria = new Criteria();
//Nom du projet
if (!ObjectUtils.isEmpty(mixingStationProductionRequesJson.getFgcmc())) {
// criteria.and("fgcmc").regex(".*?" + mixingStationProductionRequesJson.getFgcmc() + ".*?");
// Nom du projet ceinture moyenne (), Cause non détectable Utilisez une barre oblique pour les parenthèses "\"Faire une évasion \(
String name=escapeExprSpecialWord(mixingStationProductionRequesJson.getFgcmc());
criteria.and("fgcmc").regex("^.*"+name+".*$");
}
Query query = Query.query(criteria);
List<MixingStationRealDataVo> list=mongoTemplate.find(query,MixingStationRealDataVo.class);
边栏推荐
- With these websites, do you still worry about job hopping without raising your salary?
- New chief maintenance personnel for QT project
- 快速排序
- Internet of things UWB technology scheme, intelligent UWB precise positioning, centimeter level positioning accuracy
- Tencent side
- 源代码加密技术科普
- Convenient and easy to master, vivo intelligent remote control function realizes the control of household appliances in the whole house
- Take you to develop an efficiency enhancing tool -- vscode plug-in
- Interaction between C language and Lua (practice 3)
- 图的DFS
猜你喜欢

IDEA藍屏的解决方案

Low power radar sensing module, application of smart lock radar sensing scheme, smart radar sensor technology

IDEA蓝屏的解决方案

SQL operation: with expression and its application

低功耗雷达感应模组,智能锁雷达感应方案应用,智能雷达传感器技术

When the move protocol beta is in progress, the ecological core equity Momo is divided

Topological sorting

WPF DataContext usage (2)

Qt项目的新首席维护人员

树的存储结构
随机推荐
Thinkphp 的sesssion在同一个控制器不同的方法无法获取session的原因和对策
二叉树线索化
順序錶的基本操作
fc2新域名有什么价值?如何解析到网站?
yum命令
DFS of graph
低功耗雷达感应模组,智能锁雷达感应方案应用,智能雷达传感器技术
插入排序
ln n, n^k , a^n, n!, n^n的极限问题
SQL operation: with expression and its application
Take you to develop an efficiency enhancing tool -- vscode plug-in
[BP regression prediction] optimize BP regression prediction based on MATLAB GA (including comparison before optimization) [including Matlab source code 1901]
FaceShifter. ipynb
Idea blue screen solution
Tencent side
Qt项目的新首席维护人员
active RM机子断电后,RM HA切换正常。但是YarnUI上查看不到集群资源,application也一直处于ACCEPTED状态。
快速排序
哈夫曼树
Larave database backup scheduled task