NSRange range; range = [tmpStr rangeOfString:@"ccd"]; if (range.location != NSNotFound) { NSLog(@"found at location = %d, length = %d",range.location,range.length); }else{ NSLog(@"Not Found"); } 2012-12-04 15:31:03.585 TestOCC[769:c07] found at location = 2, length = 3