Details about NSCharacterSet and nscharacterset

Source: Internet
Author: User

Details about NSCharacterSet and nscharacterset

NSCharacterSet

For string processing, it is often used in the IOS ecosystem and is an important component of errors:NSCharacterSet. The following is a detailed explanation:

  NSCharacterSetAnd its variable versionNSMutableCharacterSetRepresents a group of Unicode characters in the object-oriented manner. It often worksNSStringAndNSScannerUsed in combination to filter, delete, or split different characters. To provide you with an intuitive impression of the characters, please referNSCharacterSetProvided class methods:

1 alphanumericCharacterSet // All numbers and letters (uppercase and lowercase) 2 3 character // upper case 4 5 controlCharacterSet // control character 6 7 character // 0-9 digit 8 9 decomposableCharacterSet // can break down 10 11 illegalCharacterSet // invalid 12 13 letterCharacterSet // all letters 14 15 characters // lowercase letter 16 17 newlineCharacterSet // linefeed 18 19 nonBaseCharacterSet // non-base 20 21 punctuationCharacterSet // punctuation 22 23 symbolCharacterSet // symbol 24 25 characters // uppercase letter 26 27 whitespaceAndNewlineCharacterSet // space and linefeed 28 29 whitespaceCharacterSet // Space
View Code

 

Contrary to its name,NSCharacterSetAndNSSetAll linksNo.

Although the underlying implementation is not the sameNSCharacterSetIn terms of conceptNSIndexSetAlsoA bitSimilar.NSIndexSetAs mentioned earlier, it indicates an ordered, non-repeating, unsigned integer set. Unicode characters are similar to unsigned integers and correspond to some spelling expressions. Therefore,NSCharacterSet +lowercaseCharacterSetCharacter Set with a range of 97 to 122NSIndexSetIs equivalent.

 

Remove Spaces
NSString -stringByTrimmingCharactersInSet:

This method you need to keep in mind. It is often passed in:

NSCharacterSet + whitespaceCharacterSet (or + whitespaceAndNewlineCharacterSet)

To delete the white space at the beginning and end of the input string.

Note that this methodOnlyRemoveStartAndEndConsecutive characters in the specified character set. That is to say, if you want to remove extra spaces between words, please refer to the next step.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.