i'm trying to copy strings from nspasteboard to nstextfield and exclude everything but numbers and decimals
that will exclude only the things i list which will still copy the things i don't list
that will only allow numbers and i need decimals with it
that will only allow numbers and decimals but it still copies characters if they are in the middle of a string
is there a way that i can numbers and digits and exclude everything else
edit
don't worry about it i think i solved it
Code:
NSPasteboard*mypasteboard = [NSPasteboard generalPasteboard];
NSString*mystring=[mypasteboard stringForType:NSPasteboardTypeString];
NSCharacterSet *doNotWant = [NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyz"];
mystring = [[mystring componentsSeparatedByCharactersInSet: doNotWant] componentsJoinedByString: @""];
that will exclude only the things i list which will still copy the things i don't list
Code:
NSPasteboard*mypasteboard = [NSPasteboard generalPasteboard];
NSString*mystring=[mypasteboard stringForType:NSPasteboardTypeString];
NSString *newString = [[mystring componentsSeparatedByCharactersInSet:
[[NSCharacterSet decimalDigitCharacterSet] invertedSet]]
componentsJoinedByString:@""];
that will only allow numbers and i need decimals with it
Code:
NSPasteboard*mypasteboard = [NSPasteboard generalPasteboard];
NSString*mystring=[mypasteboard stringForType:NSPasteboardTypeString];
NSCharacterSet *numbers = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789."] invertedSet];
NSString *newvalue = [mystring stringByTrimmingCharactersInSet:numbers];
that will only allow numbers and decimals but it still copies characters if they are in the middle of a string
is there a way that i can numbers and digits and exclude everything else
edit
don't worry about it i think i solved it
PHP:
NSPasteboard*mypasteboard = [NSPasteboard generalPasteboard];
NSString*mystring=[mypasteboard stringForType:NSPasteboardTypeString];
NSString *newstring = [[mystring componentsSeparatedByCharactersInSet:
[[NSCharacterSet characterSetWithCharactersInString:@"0123456789."]
invertedSet]]
componentsJoinedByString:@""];
Last edited: