Querying with apostrophe in string


How do I query objects that have apostrophe in the string? As soon as I insert an apostrophe into the query, the result will become empty. Tried escaping with \’ or using Javascript’s escape(string) does not help.

Here’s a snippet of my code.

let result = repository.objects('Products').filtered("Name CONTAINS[c] $0", "Allen's")



Realm seems to treat the apostrophe and single quote differently. I think you’d find that the following would return what you want. Looking at what you have typed, you’ve used a single quote. I’d be willing to bet your data is stored with an apostrophe.

name contains[c] "Allen’s" or name contains[c] "Allen's"

(Note: Just to confuse matters, when I use my normal single quote button on my mac in my RN app it enters a apostrophe. When I use the same button in realm studio it enters a single quote. I can however force an apostrophie on my mac with shift+option+])

Hope this helps.