Reputation: 311
I read data from an API and I see this string: text = "\n\Ufeff211419";
How can can process it to have the result: 211419
? I used trim
function of NSString
, but it did not work.
Thank you very much!
Upvotes: 0
Views: 140
Reputation: 8460
try this one,
NSString *strippedString=@"";
NSString *originalString = @"1This is my string.#/hfg34y387t59hguhfytfrg64r34nfr31234";
for (int i=0; i<[originalString length]; i++) {
if (isdigit([originalString characterAtIndex:i])) {
strippedString=[NSString stringWithFormat:@"%@%c",strippedString,[originalString characterAtIndex:i]];
}
}
NSLog(@"string is%@",strippedString);
Upvotes: 1