从给定的字符串中获取字符串

时间:2017-11-11 09:22:20

标签: objective-c nsstring

我希望在' \'之后获取字符串值来自这个NSString

   NSString *text = @"\"jkhfjkhfds" ;

我该怎么做?

2 个答案:

答案 0 :(得分:1)

@madhev试试这个..

NSString *text = @"\"jkhfjkhfds";
    NSArray *arrSeparate = [text componentsSeparatedByString:@"\""];
    NSLog(@"result = %@",[arrSeparate objectAtIndex:1]);

答案 1 :(得分:0)

NSString *text = @"\"jkhfjkhfds" ;  
text = [text stringByReplacingOccurrencesOfString:@"\\" withString:@""];  
text= [text stringByReplacingOccurrencesOfString:@"\"" withString:@""];  
NSLOg( NSLog(@"result = %@",text)`;`