简体   繁体   English

Django MySQL与iRegex搜索进行精确单词匹配

[英]Django MySQL Exact Word Match With iRegex Search

I am trying to get a column that has an exact word say yax and not yaxx but I keep getting the two for whichever one that search for. 我想获得一个具有确切说一句话YAX而不是yaxx列,但我不断收到两个用于哪一个是搜索。 I want only yax when I search for yax regardless of case. 我想只有当YAX我搜索YAX不区分大小写。

I have tried: 我努力了:

key = 'yax'
query = Model.objects.filter(content__iregex=r"[[:<:]]*{0}*[[:>:]]".format(key))

Answers I have checked but didn't quite help me: 我检查过但对我没有帮助的答案:

  1. This... 这个...
  2. And this... 和这个...
  3. And this too... 这也是...

从正则表达式中删除*

query = Model.objects.filter(content__iregex=r"[[:<:]]{0}[[:>:]]".format(key))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM