i have nsarray this: "test01_asdf","test01_efgh","test02_ghjk". need filter items using nspredicate contains, have limit filtering action range characters after 7th one.
mean: forget "testnn_" part, use contains filter rest of strings ("asdf","efgh","ghjk"). if searching text "e", return "test01_efgh" , not items, since contains "e" in word "test". i'm black box receives input , have give output.
by have line:
nspredicate *predicatefilter = [nspredicate predicatewithformat:@"self contains[cd] %@", [myfilterstring lowercasestring]];
use matches instead of contains.
nsarray *a = @[ @"test_abc", @"test_def" ]; nsstring *search = [nsstring stringwithformat:@".*_.*%@.*", @"c"]; nslog(@"%@", [a filteredarrayusingpredicate:[nspredicate predicatewithformat:@"self matches %@", search]]); the above code prints: test_abc
Comments
Post a Comment