Vignesh Babu
Vignesh Babu

Reputation: 690

How to split the numbers and characters in to two strings in objective c?

I want to split the string like FG12344 in to FG and 12344 using Objective C. I don't how to do this, please help me in this issue?

Upvotes: 4

Views: 1603

Answers (2)

Abhinav
Abhinav

Reputation: 1490

you can use NSPredicate for similar cases.

Upvotes: 0

Ruben Marin
Ruben Marin

Reputation: 1637

For the characters:

NSString *characters = [@"FG12344" stringByTrimmingCharactersInSet:[NSCharacterSet decimalDigitCharacterSet]];

For the numbers:

NSString *numbers = [@"FG12344" stringByTrimmingCharactersInSet:[NSCharacterSet letterCharacterSet]];

Upvotes: 14

Related Questions