I am trying to get DOE, JOHN from below NSString:
IDCHK9898960101DL00300171DL1ZADOE,JOHN
I tried to split the string into 1ZA since it will be constant.
Here is what I have tried so far, but this gives me the opposite of what I'm looking for:
NSString *getTheNameOuttaHere = @"IDCHK9898960101DL00300171DL1ZADOE,JOHN"; // scan for "1ZA" NSString *separatorString = @"1ZA"; NSScanner *aScanner = [NSScanner scannerWithString:getTheNameOuttaHere]; NSString *thingsScanned; [aScanner scanUpToString:separatorString intoString:&thingsScanned]; NSLog(@"container: %@", thingsScanned);
Exit:
container: IDCHK9898960101DL00300171DL
Any help would be great! Thanks!
source share