objective c - Position of a character NSString -
i have string contains either ,b, c, or d (example a123 or b235 or 2b35 not ab123)
i want find index of a,b,c or d
in c # write as
string s = "123b"; index = s.indexofany(new char[] = {a,b,c,d});
how write in objective-c??
you can use -rangeofcharacterfromset:
:
nscharacterset *charset = [nscharacterset charactersetwithcharactersinstring:@"abcd"]; nsrange range = [string rangeofcharacterfromset:charset]; if (range.location == nsnotfound) { // ... oops } else { // range.location index }
Comments
Post a Comment