0

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

   NSString *text = @"\"jkhfjkhfds" ;

How can I do it??

3
  • 1
    The \ is used to escape the " why do you want to remove it? Commented Nov 11, 2017 at 9:34
  • For example with substringFromIndex or stringByTrimmingCharactersInSet Commented Nov 11, 2017 at 9:36
  • There is no \ in the NSString value, only in the literal used to form it. The value of the NSString Produced by the literal is "jkhfjkhfds. What exactly do you need to do? What methods from NSString and/or NSRegularExpression have you tried, and what did not work in your attempted solutions? Edit your question to provide details and someone will undoubtedly help you. HTH Commented Nov 11, 2017 at 13:14

2 Answers 2

1

@madhev try this..

NSString *text = @"\"jkhfjkhfds";
    NSArray *arrSeparate = [text componentsSeparatedByString:@"\""];
    NSLog(@"result = %@",[arrSeparate objectAtIndex:1]);
Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.