简体   繁体   中英

iOS predicate for searching each word in a string of an array

I have an array and I want to implement autocomplete with it. The autocomplete should work in such a way that for eg:

I am searching a string pi

It should return the string big pizza as pi is the start of the 2nd word. I have implemented :

    NSPredicate *pred = [NSPredicate predicateWithFormat:@"stationName CONTAINS[cd] %@", substring];

This is returning me all strings which have the string as a part of it. I want string which have the string present at the start of any word.

您需要使用MATCHES运算符(使用ICU的正则表达式 )来匹配对所有规则进行编码的表达式。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM