/* Remove lines from a text file that start with # Original Source: (See copyright notice at ) */ /* Find all lines starting with # and remove them. Returns a new string with lines separated by \n but it would be easy to modify this to return an array of lines, if you wanted to then parse them. Requires -[NSString componentsSeparatedByLineSeparators]. */ - (NSString *) removeCommentedLines; { NSArray *lines = [self componentsSeparatedByLineSeparators]; int count = [lines count]; NSMutableArray *lines2 = [NSMutableArray arrayWithArray:lines]; int i; for ( i = 0 ; i < count ; i++ ) { if ([[[lines objectAtIndex:i] condenseWhiteSpace] hasPrefix:@"#"]) { [lines2 replaceObjectAtIndex:i withObject:[NSNull null]]; } } [lines2 removeObjectIdenticalTo:[NSNull null]]; NSString *result = [lines2 componentsJoinedByString:@"\n"]; return result; }