0
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.

kmatyaszek
  • 19,016
  • 9
  • 60
  • 65
NNikN
  • 3,720
  • 6
  • 44
  • 86

1 Answers1

1

Try ([A-L]+\\.[^\\s]*).

[^\\s]* will match everything that is not a space.

This gives me:

NEW str= AA.BB
NEW str= CC.JJ
NEW str= BB.CC
Nathan Villaescusa
  • 17,331
  • 4
  • 53
  • 56