NSString *inputStr=@"AA.BB Hello \nCC.JJ Say \nBB.CC Bye \nZZ.AA To";
NSRange r;
while ((r=[inputStr rangeOfString:@"(^[A-L].*)" options:NSRegularExpressionSearch]).location!=NSNotFound) {
NSString *newStr=[inputStr substringWithRange:r];
inputStr=[inputStr stringByReplacingCharactersInRange:r withString:@""];
NSLog(@"NEW str= %@",newStr);
}
It gives: AA.BB Hello.
But, I am looking for suffix which are in the range A-L, as below
AA.BB
CC.JJ
BB.CC
Then I replaced (^[A-L].\*)
by (^[A-L]*$[\\s])
. So it must start from A-L and end when it finds space. But this outputs nothing.