Re: NSScanner baffling behaviour (scanString:intoString: doesn't work!)
Re: NSScanner baffling behaviour (scanString:intoString: doesn't work!)
- Subject: Re: NSScanner baffling behaviour (scanString:intoString: doesn't work!)
- From: j o a r <email@hidden>
- Date: Tue, 8 Apr 2003 15:18:13 +0200
Try:
if ([scanner scanUpToString: startTag intoString: nil] && [scanner
scanString: startTag intoString: nil])
{
if ([scanner scanUpToString: endTag intoString: &result])
{
NSLog(@"result: %@", result);
}
}
j o a r
On Tuesday, Apr 8, 2003, at 11:51 Europe/Stockholm, Greg Hurrell wrote:
+ (NSString *)_scanString:(NSString *)source
startTag:(NSString *)startTag
endTag:(NSString *)endTag
{
NSScanner *scanner = [NSScanner scannerWithString:source];
NSString *result = nil;
// first try for startTag
if (![scanner scanString:startTag intoString:nil])
// startTag not found!
return nil;
// then end tag
if ([scanner scanUpToString:endTag intoString:&result])
// known bug: if endTag doesn't appear in source string, will
return entire rest of string!
return result;
else
return nil;
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.