Re: CharacterSet: CharSet("A") - CharSetUnicode = remainder ?
Re: CharacterSet: CharSet("A") - CharSetUnicode = remainder ?
- Subject: Re: CharacterSet: CharSet("A") - CharSetUnicode = remainder ?
- From: Charles Srstka <email@hidden>
- Date: Sat, 24 Apr 2010 13:33:03 -0500
On Apr 24, 2010, at 1:17 PM, Filip van der Meeren wrote:
>
> On 24 Apr 2010, at 18:38, Charles Srstka wrote:
>
>> On Apr 24, 2010, at 5:50 AM, Filip van der Meeren wrote:
>>
>>> I want to get the difference between 2 characterSets. For example:
>>>
>>> I have the following 2 characterSets...
>>> NSCharacterSet *aSet = [NSCharacterSet characterSetWithCharactersInString:@"a"];
>>> NSCharacterSet *lowerSet = [NSCharacterSet lowercaseLetterCharacterSet];
>>>
>>> The difference between these (aSet - lowerSet = remainder):
>>
>> IIRC, this line right here gets you an empty character set, which will also give you an empty set any time you make an intersection with anything:
>>
>>> NSMutableCharacterSet *remainder = [[NSMutableCharacterSet alloc] init];
>>
>> so this one will get the intersection between ('a') and the empty set, which will be the empty set:
>>
>>> [remainder formIntersectionWithCharacterSet:aSet];
>>
>> and ditto for this one. Note that even if remainder started out non-empty, it wouldn’t have more than (‘a') in it after the first intersection, and since 'a' is a member of lowerSet, being a lowercase letter, intersecting with [lowerSet invertedSet] is still going to get you an empty set:
>>
>>> [remainder formIntersectionWithCharacterSet:[lowerSet invertedSet]];
>>
>> What exactly are you trying to do?
>>
>> Charles
>
> What I was trying to do is the following:
>
> C/C++ operator | NSCharacterSet operation
> -----------------------------------------------------------------------------
> | (or) | [aCharSet formUnionWithCharacterSet:bCharSet];
> & (and) | [aCharSet formIntersectionWithCharacterSet:bCharSet];
> ^ (xor) | ?
How about something like this?
NSCharacterSet *aSet = [NSCharacterSet characterSetWithCharactersInString:@"aA”];
NSCharacterSet *lowerSet = [NSCharacterSet lowercaseLetterCharacterSet];
NSMutableCharacterSet *intersect1 = [[aSet mutableCopy] autorelease];
NSMutableCharacterSet *intersect2 = [[lowerSet mutableCopy] autorelease];
[intersect1 formIntersectionWithCharacterSet:[lowerSet invertedSet]];
[intersect2 formIntersectionWithCharacterSet:[aSet invertedSet]];
[intersect1 formUnionWithCharacterSet:intersect2];
NSCharacterSet *rem = [[intersect1 copy] autorelease];
Charles_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden