If there is such a problem: there is a certain list of names (full names, names of academic groups at the university) in Ukrainian, and many Russian-speaking users who would prefer to look for these names in Russian. For an output I use tableView, and search happens through UISearchController. In this case, the predicate is configured as follows:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title CONTAINS[c] %@", searchText]; 

Is it possible to somehow change the predicate's settings so that it equally works both on the Russian "and" and on the Ukrainian "i"? The same goes for the Russian "e" and the Ukrainian "є".

I tried to replace the characters, as in the example below, but this is not exactly what you need.

 NSPredicate *predicate = [NSPredicate predicateWithFormat:@"title CONTAINS[c] %@", [searchText stringByReplacingOccurrencesOfString:@"и" withString:@"і"]]; 

    1 answer 1

    I will not say how correct it will be by the example, but in this case, use regulars.

     predicateWithFormat:@"title CONTAINS[c] %@" 

    change to

     predicateWithFormat:@"title MATCHES [cd] %@" 

    And the search string lead to the form:

     @"^(.*?)[иі]мя(.*?)" 

    As an example for a quick check:

     NSString *name = @"Это имя Иван"; NSString *searchText = @"^(.*?)[иі]ван(.*?)"; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES [cd] %@", searchText]; NSLog(@"содержит: %d", [predicate evaluateWithObject:name]);