Structure

CharacterSet

A CharacterSet represents a set of Unicode-compliant characters. Foundation types use CharacterSet to group characters together for searching operations, so that they can find any of a particular set of characters during a search.

Overview

This type provides “copy-on-write” behavior, and is also bridged to the Objective-C NSCharacterSet class.

Symbols

Type Aliases

Initializers

init()

Initialize an empty instance.

init<S>(S)

Creates a new set from a finite sequence of items.

init(arrayLiteral: (UnicodeScalar)...)

Creates a set containing the elements of the given array literal.

init(bitmapRepresentation: Data)

Initialize with a bitmap representation.

init(charactersIn: Range<UnicodeScalar>)

Initialize with a range of integers.

init(charactersIn: String)

Initialize with the characters in the given string.

init(charactersIn: ClosedRange<UnicodeScalar>)

Initialize with a closed range of integers.

init?(contentsOfFile: String)

Initialize with the contents of a file.

Instance Properties

var bitmapRepresentation: Data

Returns a representation of the CharacterSet in binary format.

var debugDescription: Stringvar description: Stringvar hashValue: Int
var inverted: CharacterSet

Returns an inverted copy of the receiver.

var isEmpty: Bool

A Boolean value that indicates whether the set has no elements.

Type Properties

static var alphanumerics: CharacterSet

Returns a character set containing the characters in Unicode General Categories L*, M*, and N*.

static var capitalizedLetters: CharacterSet

Returns a character set containing the characters in Unicode General Category Lt.

static var controlCharacters: CharacterSet

Returns a character set containing the characters in Unicode General Category Cc and Cf.

static var decimalDigits: CharacterSet

Returns a character set containing the characters in the category of Decimal Numbers.

static var decomposables: CharacterSet

Returns a character set containing individual Unicode characters that can also be represented as composed character sequences (such as for letters with accents), by the definition of “standard decomposition” in version 3.2 of the Unicode character encoding standard.

static var illegalCharacters: CharacterSet

Returns a character set containing values in the category of Non-Characters or that have not yet been defined in version 3.2 of the Unicode standard.

static var letters: CharacterSet

Returns a character set containing the characters in Unicode General Category L* & M*.

static var lowercaseLetters: CharacterSet

Returns a character set containing the characters in Unicode General Category Ll.

static var newlines: CharacterSet

Returns a character set containing the newline characters (U+000A ~ U+000D, U+0085, U+2028, and U+2029).

static var nonBaseCharacters: CharacterSet

Returns a character set containing the characters in Unicode General Category M*.

static var punctuationCharacters: CharacterSet

Returns a character set containing the characters in Unicode General Category P*.

static var symbols: CharacterSet

Returns a character set containing the characters in Unicode General Category S*.

static var uppercaseLetters: CharacterSet

Returns a character set containing the characters in Unicode General Category Lu and Lt.

static var urlFragmentAllowed: CharacterSet

Returns the character set for characters allowed in a fragment URL component.

static var urlHostAllowed: CharacterSet

Returns the character set for characters allowed in a host URL subcomponent.

static var urlPasswordAllowed: CharacterSet

Returns the character set for characters allowed in a password URL subcomponent.

static var urlPathAllowed: CharacterSet

Returns the character set for characters allowed in a path URL component.

static var urlQueryAllowed: CharacterSet

Returns the character set for characters allowed in a query URL component.

static var urlUserAllowed: CharacterSet

Returns the character set for characters allowed in a user URL subcomponent.

static var whitespaces: CharacterSet

Returns a character set containing the characters in Unicode General Category Zs and CHARACTER TABULATION (U+0009).

static var whitespacesAndNewlines: CharacterSet

Returns a character set containing characters in Unicode General Category Z*, U+000A ~ U+000D, and U+0085.

Instance Methods

func contains(UnicodeScalar)

Test for membership of a particular UnicodeScalar in the CharacterSet.

func formIntersection(CharacterSet)

Sets the value to an intersection of the CharacterSet with another CharacterSet.

func formSymmetricDifference(CharacterSet)

Sets the value to an exclusive or of the CharacterSet with another CharacterSet.

func formUnion(CharacterSet)

Sets the value to a union of the CharacterSet with another CharacterSet.

func hasMember(inPlane: UInt8)

Returns true if the CharacterSet has a member in the specified plane.

func insert(UnicodeScalar)

Insert a UnicodeScalar representation of a character into the CharacterSet.

func insert(charactersIn: String)

Insert the values from the specified string into the CharacterSet.

func insert(charactersIn: Range<UnicodeScalar>)

Insert a range of integer values in the CharacterSet.

func insert(charactersIn: ClosedRange<UnicodeScalar>)

Insert a closed range of integer values in the CharacterSet.

func intersection(CharacterSet)

Returns an intersection of the CharacterSet with another CharacterSet.

func invert()

Invert the contents of the CharacterSet.

func isDisjoint(with: CharacterSet)

Returns a Boolean value that indicates whether the set has no members in common with the given set.

func isStrictSubset(of: CharacterSet)

Returns a Boolean value that indicates whether this set is a strict subset of the given set.

func isStrictSuperset(of: CharacterSet)

Returns a Boolean value that indicates whether this set is a strict superset of the given set.

func isSubset(of: CharacterSet)

Returns a Boolean value that indicates whether the set is a subset of another set.

func isSuperset(of: CharacterSet)

Returns true if self is a superset of other.

func remove(UnicodeScalar)

Remove a UnicodeScalar representation of a character from the CharacterSet.

func remove(charactersIn: ClosedRange<UnicodeScalar>)

Remove a closed range of integer values from the CharacterSet.

func remove(charactersIn: String)

Remove the values from the specified string from the CharacterSet.

func remove(charactersIn: Range<UnicodeScalar>)

Remove a range of integer values from the CharacterSet.

func subtract(CharacterSet)

Removes the elements of the given set from this set.

func subtract(CharacterSet)

Sets the value to a CharacterSet created by removing elements in other from self.

func subtracting(CharacterSet)

Returns a CharacterSet created by removing elements in other from self.

func symmetricDifference(CharacterSet)

Returns an exclusive or of the CharacterSet with another CharacterSet.

func union(CharacterSet)

Returns a union of the CharacterSet with another CharacterSet.

func update(with: UnicodeScalar)

Insert a UnicodeScalar representation of a character into the CharacterSet.

Operator Functions

static func ==(CharacterSet, CharacterSet)

Returns true if the two CharacterSets are equal.