I’m using Parse as the backend for my iOS app (they add their own framework to the project adding methods for use with their database). Its a simple database that includes a column with the names of the files I stored. Right now, when I query using their containsString method, which only returns results with matching cases for every letter. So searching for “john” will NOT return “John”. But they do have the option of using a matchesRegex method that allows for regular expressions input. I want to know how I can use regex to say that the result should contain my input string, but needs to ignore its case? So if I search for “john”, it will match it with “John”, “JOHN”, etc.
So it would look something like:
[query whereKey:@"file_name" matchesRegex:@"something_that_returns_all_johns"];
They use PERL compatible regular expressions.
In PCREs, you can mark just part of a regex as case-insensitive by wrapping it in
(?i:...)or preceding it with(?i). Usually there’s a separate, out-of-band way to indicate that the whole regex is case-insensitive, but if the Parse API doesn’t offer such a way, then you can just apply the part-of-the-regex approach to the whole regex, using either of these:(assuming that Parse supports these features of PCREs: it probably does).