开发者

String Manipulation in iPhone

开发者 https://www.devze.com 2022-12-21 11:38 出处:网络
I am having a lengthy string which contains alphabets and a special character like \"|\". i need to split this strings based on the \"|\" delimiter and store the individual string in to 开发者_如何学编

I am having a lengthy string which contains alphabets and a special character like "|". i need to split this strings based on the "|" delimiter and store the individual string in to 开发者_如何学编程an array. Is there any string function which helps us to do the same.?

Thanks, Shibin.


Sounds like you need componentsSeparatedByString:

NSString *string = @"hello|how|are|you";
NSArray *array = [string componentsSeparatedByString:@"|"]; 
NSLog(@"array: %@", array);

Output:

array: (
    hello,
    how,
    are,
    you
    )
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号