Getting the substring from a certain character in NSString
问题 If I have an NSString that is initially: "ABCDE*FGHI" How do I make it turn into "FGHI" In other words, everything from the asterisk onwards is kept. Likewise, how would I turn it into: "ABCDE" (everything up to the asterisk is kept) Thanks 回答1: NSString *myString = @"ABCDE*FGHI"; NSArray *myArray = [myString componentsSeparatedByString:@"*"]; key 0 of myArray will contain @"ABCDE" key 1 will contain @"FGHI" If you want more than one character to be the separator, use