Re: NSScanner stoopid question
Re: NSScanner stoopid question
- Subject: Re: NSScanner stoopid question
- From: Koen van der Drift <email@hidden>
- Date: Mon, 7 Apr 2003 09:44:51 -0400
At 11:36 AM -0500 4/5/03, Jonathan Jackel wrote:
On Friday, April 4, 2003, at 09:34 PM, Koen van der Drift wrote:
Hi,
I am scanning a string for a specific character. However, if the next
character belongs to another NSCharacterSet, I should not continue with the
algorithm.
Here's a snippet:
NSScanner *scanner = [NSScanner scannerWithString: myString];
int len = [myString length];
int current;
while (![scanner isAtEnd])
{
[scanner scanUpToCharactersFromSet: firstSet intoString:nil];
current = [scanner scanLocation];
if ( len != current + 1 )
{
if ( ![restrictionSet characterIsMember:
[myString characterAtIndex: current + 1 ]])
{
...
}
}
}
I think what you want is if(len > current +1)
Yes, thanks,
And I also need to add a [scanner setScanLocation:current + 1],
otherwise the scanner will never advance after afirst match.
- Koen.
_______________________________________________
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.