1

I've a string with this kind of value /finocchi$FINOCCHamelo

Now I need a new string with only this part of the word FINOCCHamelo

I've try this:

NSString * newString = [item.label stringByReplacingOccurrencesOfString:@"$" withString:@""];

But it's not right becouse change the $ with blank char. I need to filter the string afther $ How Can I do?

rene
  • 41,474
  • 78
  • 114
  • 152

1 Answers1

1

Assuming in all the case you have only one $ in your string and you need the value after $.

NSArray *brokenStrings = [item.label componentsSeparatedByString:@"$"];
NSString *filteredString = [brokenStrings objectAtIndex:1];

There are a lot more ways to do this: You can opt any one from these methods, or dozen other methods are available in NSString.

– componentsSeparatedByString:
– substringFromIndex:
- rangeOfString:
– stringByTrimmingCharactersInSet:
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140