ReB
ReB

Reputation: 117

Get the string from the given string

I want get the string value after the '\' from this NSString

   NSString *text = @"\"jkhfjkhfds" ;

How can I do it??

Upvotes: 0

Views: 54

Answers (2)

narasimha
narasimha

Reputation: 57

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

Upvotes: 0

Nirav Kotecha
Nirav Kotecha

Reputation: 2581

@madhev try this..

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

Upvotes: 1

Related Questions