NSCharacterSet
NSCharacterSet 表示一组字符的集合,常用于字符串扫描/过滤/拆分等场景。
类成员 (Class members)
Section titled “类成员 (Class members)”常用预置集合
Section titled “常用预置集合”controlCharacterSet
Section titled “controlCharacterSet”控制字符集。
static controlCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
whitespaceCharacterSet
Section titled “whitespaceCharacterSet”空白字符集。
static whitespaceCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
whitespaceAndNewlineCharacterSet
Section titled “whitespaceAndNewlineCharacterSet”空白与换行字符集。
static whitespaceAndNewlineCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
newlineCharacterSet
Section titled “newlineCharacterSet”换行字符集。
static newlineCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
decimalDigitCharacterSet
Section titled “decimalDigitCharacterSet”十进制数字字符集。
static decimalDigitCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
letterCharacterSet
Section titled “letterCharacterSet”字母字符集。
static letterCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
lowercaseLetterCharacterSet
Section titled “lowercaseLetterCharacterSet”小写字母字符集。
static lowercaseLetterCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
uppercaseLetterCharacterSet
Section titled “uppercaseLetterCharacterSet”大写字母字符集。
static uppercaseLetterCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
capitalizedLetterCharacterSet
Section titled “capitalizedLetterCharacterSet”首字母大写字符集。
static capitalizedLetterCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
alphanumericCharacterSet
Section titled “alphanumericCharacterSet”字母数字字符集。
static alphanumericCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
nonBaseCharacterSet
Section titled “nonBaseCharacterSet”非基础字符集。
static nonBaseCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
decomposableCharacterSet
Section titled “decomposableCharacterSet”可分解字符集。
static decomposableCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
illegalCharacterSet
Section titled “illegalCharacterSet”非法字符集。
static illegalCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
punctuationCharacterSet
Section titled “punctuationCharacterSet”标点字符集。
static punctuationCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
symbolCharacterSet
Section titled “symbolCharacterSet”符号字符集。
static symbolCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
URL 相关预置集合
Section titled “URL 相关预置集合”URLUserAllowedCharacterSet
Section titled “URLUserAllowedCharacterSet”URL 用户部分允许字符集。
static URLUserAllowedCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
URLPasswordAllowedCharacterSet
Section titled “URLPasswordAllowedCharacterSet”URL 密码部分允许字符集。
static URLPasswordAllowedCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
URLHostAllowedCharacterSet
Section titled “URLHostAllowedCharacterSet”URL 主机部分允许字符集。
static URLHostAllowedCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
URLPathAllowedCharacterSet
Section titled “URLPathAllowedCharacterSet”URL 路径部分允许字符集。
static URLPathAllowedCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
URLQueryAllowedCharacterSet
Section titled “URLQueryAllowedCharacterSet”URL 查询部分允许字符集。
static URLQueryAllowedCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
URLFragmentAllowedCharacterSet
Section titled “URLFragmentAllowedCharacterSet”URL 片段部分允许字符集。
static URLFragmentAllowedCharacterSet(): NSCharacterSetReturn Value:
NSCharacterSet: 预置集合。
characterSetWithRange
Section titled “characterSetWithRange”从 Unicode 范围创建。
static characterSetWithRange(aRange: any): NSCharacterSetParameters:
| Name | Type | Description |
|---|---|---|
aRange | any | 范围(如 { location, length })。 |
Return Value:
NSCharacterSet: 新实例。
characterSetWithCharactersInString
Section titled “characterSetWithCharactersInString”从字符串中的字符创建。
static characterSetWithCharactersInString(aString: string): NSCharacterSetParameters:
| Name | Type | Description |
|---|---|---|
aString | string | 字符来源字符串。 |
Return Value:
NSCharacterSet: 新实例。
characterSetWithBitmapRepresentation
Section titled “characterSetWithBitmapRepresentation”从位图数据创建。
static characterSetWithBitmapRepresentation(data: NSData): NSCharacterSetParameters:
| Name | Type | Description |
|---|---|---|
data | NSData | 位图数据。 |
Return Value:
NSCharacterSet: 新实例。
characterSetWithContentsOfFile
Section titled “characterSetWithContentsOfFile”从文件内容创建。
static characterSetWithContentsOfFile(fName: string): NSCharacterSetParameters:
| Name | Type | Description |
|---|---|---|
fName | string | 文件路径。 |
Return Value:
NSCharacterSet: 新实例。
实例成员 (Instance members)
Section titled “实例成员 (Instance members)”characterIsMember
Section titled “characterIsMember”某字符是否在集合中。
characterIsMember(aCharacter: number): booleanParameters:
| Name | Type | Description |
|---|---|---|
aCharacter | number | Unicode 码点。 |
Return Value:
boolean: 是否在集合中。
longCharacterIsMember
Section titled “longCharacterIsMember”某长字符(如 surrogate pair)是否在集合中。
longCharacterIsMember(theLongChar: number): booleanParameters:
| Name | Type | Description |
|---|---|---|
theLongChar | number | 长字符码点。 |
Return Value:
boolean: 是否在集合中。
isSupersetOfSet
Section titled “isSupersetOfSet”是否包含另一字符集的所有字符。
isSupersetOfSet(other: NSCharacterSet): booleanParameters:
| Name | Type | Description |
|---|---|---|
other | NSCharacterSet | 另一字符集。 |
Return Value:
boolean: 是否为超集。
hasMemberInPlane
Section titled “hasMemberInPlane”指定 plane 是否有成员。
hasMemberInPlane(thePlane: number): booleanParameters:
| Name | Type | Description |
|---|---|---|
thePlane | number | Unicode plane。 |
Return Value:
boolean: 是否有成员。
bitmapRepresentation
Section titled “bitmapRepresentation”位图表示。
bitmapRepresentation(): NSDataReturn Value:
NSData: 位图数据。
invertedSet
Section titled “invertedSet”取反字符集(不在当前集合中的字符)。
invertedSet(): NSCharacterSetReturn Value:
NSCharacterSet: 取反后的新字符集。