Questions tagged [nscharacterset]

An NSCharacterSet object represents a set of Unicode-compliant characters. NSString and NSScanner objects use NSCharacterSet objects to group characters together for searching operations, so that they can find any of a particular set of characters during a search. The cluster’s two public classes, NSCharacterSet and NSMutableCharacterSet, declare the programmatic interface for static and dynamic character sets, respectively.

102 questions
2
votes
1 answer

EXC BAD ACCESS while creating a new CharacterSet

I'm trying to write a slugging function which involves stripping out any punctuation characters except for hyphens. I thought the best way to do this would be to create a new CharacterSet as follows: import Foundation extension CharacterSet { …
Noah
  • 1,329
  • 11
  • 21
2
votes
2 answers

IOS NSCharacterSet for emoji and latin characters

I'm trying to limit text user input to latin/english characters and emojis. Is it possible to create an NSCharacterSet that includes all of these characters? I tried using a keyboard type ASCIICapable on my input views, but then I don't get emoji…
Julio Garcia
  • 665
  • 6
  • 17
2
votes
5 answers

How to strip special characters out of string?

I have a set with the characters I allow in my string: var characterSet:NSCharacterSet = NSCharacterSet(charactersInString: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLKMNOPQRSTUVWXYZ") I want to strip any other characters from a string so two…
Roberto
  • 11,557
  • 16
  • 54
  • 68
2
votes
1 answer

Defining a custom PURE Swift Character Set

So, using Foundation you can use NSCharacterSet to define character sets and test character membership in Strings. I would like to do so without Cocoa classes, but in a purely Swift manner. Ideally, code could be used like so: struct…
Sean
  • 377
  • 3
  • 12
2
votes
0 answers

Objective C: How to recognise unicode characters that display the 'Alien' or '?' symbol on the iPhone

I'm currently working on a project involving filling the address book of an iPhone. One requirement of this task is that the address book is filled with random UTF-8 characters. However, some of these appear as an 'alien-head' or '?' (Sorry I need…
Tom Cornish
  • 71
  • 1
  • 5
2
votes
1 answer

Generate a random string from NSCharacterSet

I have the following NSCharacterSet and want to generate a random string valid for that character set. NSMutableCharacterSet *characterSet = [NSMutableCharacterSet alphanumericCharacterSet]; [characterSet formUnionWithCharacterSet:[NSCharacterSet…
Ozgur Vatansever
  • 49,246
  • 17
  • 84
  • 119
2
votes
1 answer

Swift: Check if first character of String is ASCII or a letter with an accent

In Swift, how do I check whether the first character of a String is ASCII or a letter with an accent? Wider characters, like emoticons & logograms, don't count. I'm trying to copy how the iPhone Messages app shows a person's initials beside their…
ma11hew28
  • 121,420
  • 116
  • 450
  • 651
2
votes
1 answer

Prevent user entering a certain character on search bar

Is it possible to prevent the user to enter certain characters on search bar while typing. For example, the user types some string... "This is a text " and after word text the user tries enter an '*' character. I wish to prevent the user from…
tech_human
  • 6,592
  • 16
  • 65
  • 107
2
votes
5 answers

Allow only alpha numeric characters in UITextView

Is there anyway i can allow user to enter only alpha numeric characters in a text view and no other character. EDIT: Tried, if ([_txtView.text rangeOfCharacterFromSet:alphaSet].location != NSNotFound) { UIAlertView* alert = [[UIAlertView…
user2268539
  • 173
  • 2
  • 3
  • 14
2
votes
5 answers

how to use stringByTrimmingCharactersInSet in NSString

I have a string which gives the Date (below) NSString*str1=[objDict objectForKey:@"date"]; NSLog(@" str values2%@",str1); --> 04-Jan-13 Now Problem is I need to Trim the"-13" from here .I know about NSDateFormatter to format date.but I can't do…
Christien
  • 1,213
  • 4
  • 18
  • 32
1
vote
2 answers

Breaking Up a String in Objective-C

All, I have a method that takes a date (YYYY-MM-DD H:M:S) from the database and creates a URL with the year, month and day components from the date string. My solution works but I was wondering if there is a better way to do this? How are the cool…
Slinky
  • 5,662
  • 14
  • 76
  • 130
1
vote
1 answer

Replace words using the matching regex code

I need to replace the words in a given string using Swift Regular Expression. Ignore numbers (ex: 2000 or 2,000) But if a number contains characters, replace it (ex: H3llo) let givenString = "I will keep this 3,000 short. It is a quite common task…
1
vote
2 answers

Retrieve only positive integers from a given string

I have the following implementation where a comboKey is a string that I am trying to retrieve the integers. For example if the comboKey is 2m1s and then it returns @[@"2",@"1"]; which is perfect. If comboKey is 0m2s and then it returns …
casillas
  • 16,351
  • 19
  • 115
  • 215
1
vote
1 answer

Crash (EXC_BAD_ACCESS) when using CharacterSet isSuperset

Trying to determine if an input string is a valid phone number using CharacterSet. Seems that isSubset works fine, but isSuperset will crash. I think this is a bug in Foundation. let phoneNumberCharacterSet = CharacterSet(charactersIn:…
Ric Santos
  • 15,419
  • 6
  • 50
  • 75
1
vote
2 answers

How to correctly handle dakuten and handakuten Japanese characters in mysql?

Disclaimer: Database is ut8mb4_unicode_520_ci Table field is ut8mb4_unicode_520_ci How do you correctly query a table field that contains dakuten or handakuten Japanese characters? Dakuten. Currently, it seems that the base character is returned,…
Chris
  • 54,599
  • 30
  • 149
  • 186