stringByTrimmingCharactersInSet trimming too much
stringByTrimmingCharactersInSet trimming too much
- Subject: stringByTrimmingCharactersInSet trimming too much
- From: Graeme Nattress <email@hidden>
- Date: Thu, 5 Dec 2002 10:57:49 -0500
Hi,
I'm parsing this line of a text file:
LightSource "ambientlight" 1 "intensity" [1]"lightcolor" [0 0 0]
and when I get to extract the intensity, everything is fine until I try
to trim off the leading space and square bracket. Before trimming, word
= " [1", and after trimming it's equal to "", which doesn't seem
right.... Any ideas. The code snippet below is what I'm using, and it's
working just great for extracting other values.
[wordScanner scanUpToString:@"intensity" intoString:nil];
if ([wordScanner scanString:@"intensity" intoString:nil]) {
[wordScanner setScanLocation:[wordScanner scanLocation] + 1];
[wordScanner scanUpToCharactersFromSet:[NSCharacterSet
characterSetWithCharactersInString:@"\"]" ] intoString:&word];
word = [word stringByTrimmingCharactersInSet:[NSCharacterSet
characterSetWithCharactersInString:@" \"[]" ]];
intensityString = word;
}
Thanks,
Graeme
_______________________________________________
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.