Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Realm case insensitive search syntax

Tags:

swift

realm

I get filtered objects like:

realm.objects(Post.self).filter("title contains '\(searchText)'")

But I need case insensitive search option, Realm docs say:

Case-insensitive comparisons for strings, such as name CONTAINS[c] ‘Ja’. Note that only characters “A-Z” and “a-z” will be ignored for case. Can be combined with the [d] modifier.

So how do I need do?

realm.objects(Post.self).filter("title contains[c] '\(searchText)'")

doesn't work...

UPD:

Got it. I was trying filter cyrillic symbols. So next question, where can I add cyrillic filtering?

like image 236
aaisataev Avatar asked May 02 '17 18:05

aaisataev


1 Answers

Please use NSPredicate's interpolation rather than String interpolation:

realm.objects(Post.self).filter("title contains[c] %@", searchText)
like image 160
jpsim Avatar answered Nov 21 '22 11:11

jpsim