0

I have any NSarray of NSString objects.

I want to extract those string which only contains character or character&numeric from it.

For example: "D6,Bombay.Hello”" is valid whereas “123456.123,56” is invalid.

Please help if anyone have idea.

3
  • can you share the array please? Commented Feb 3, 2017 at 9:00
  • 1
    @AntonyRaphel-here is an array ( 1.1, Detais of members, holder, more than 5% of total, d up capital, Name of the Share Holders, Mr John, ABC Limited, No. of Share, 2,34,105 74.50, 14,440 04.60, 28.940, 09.21, 2013-14, 234,105 74.50, 14,440 04.60, 28940 09.21, ) Commented Feb 3, 2017 at 9:05
  • Possbile duplicate, stackoverflow.com/questions/2753956/… Commented Feb 3, 2017 at 9:08

2 Answers 2

3

You can filter array using predicate to get only

NSPredicate *pred = [NSPredicate predicateWithBlock:^BOOL(id str, NSDictionary *unused) {
    return ([str rangeOfCharacterFromSet:[NSCharacterSet letterCharacterSet]].location != NSNotFound);
}];

NSArray *filtered = [yourArray filteredArrayUsingPredicate:pred];
Sign up to request clarification or add additional context in comments.

Comments

0
if(your_str containsString:xxx){
   // do sth
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.