Case Insensitive Search Syntax

I get filtered objects like:

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

But I need case insensitive case, Realm docs say:

Case insensitive comparisons for strings, such as the name CONTAINS [c] "Ja. Note that only the characters" AZ "and" az "will be ignored for the case. Can be combined with the modifier [d].

So how do I need to do?

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

does not work...

UPD:

Got it. I tried to filter cyrillic characters. So, the next question, where can I add Cyrillic filtering?

+4
source share
1 answer

Please use NSPredicate interpolation rather than row interpolation:

realm.objects(Post.self).filter("title contains[c] %@", searchText)
+8
source

Source: https://habr.com/ru/post/1676185/


All Articles