Yax
Yax

Reputation: 2189

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. I want only yax when I search for yax regardless of case.

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...

Upvotes: 0

Views: 533

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174816

Remove the * from your regex.

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

Upvotes: 1

Related Questions