I have a string like
NSString * aString = @"\n \n \n This is my string ";
I need to extract firs blank spaces and new line characters upto first non-whitespace non-newline character. that is the output should be
NSString *output = @"\n \n \n ";
I tried it with NSScanner
as follows
NSString * aString = @"\n \n \n This is my string ";
NSScanner *scanner = [NSScanner scannerWithString:aString];
NSCharacterSet *characterSet = [[NSCharacterSet whitespaceAndNewlineCharacterSet] invertedSet];
NSString *output = nil;
[scanner scanUpToCharactersFromSet:characterSet intoString:&output];
But after execution the output string is nil. whats wrong with this code?