One Logo Pool Ball
RegexBuilder · IOS API REFERENCE

CharacterClass

struct · iOS 16.0+ · SDK 27.1

struct CharacterClass

A class of characters that match in a regex. A character class can represent individual characters, a group of characters, the set of character that match some set of criteria, or a set algebraic combination of all of the above.

Members (7)

method · iOS 16.0+

subtracting

TypeScript
subtracting(other: CharacterClass): CharacterClass
Swift declaration
func subtracting(_ other: CharacterClass) -> CharacterClass

Returns a character class by subtracting the given class from this class.

method · iOS 16.0+

intersection

TypeScript
intersection(other: CharacterClass): CharacterClass
Swift declaration
func intersection(_ other: CharacterClass) -> CharacterClass

Returns a character class from the intersection of this class and the given class.

static · iOS 16.0+

generalCategory

TypeScript
static generalCategory(category: SDKHandle): CharacterClass
Swift declaration
static func generalCategory(_ category: Unicode.GeneralCategory) -> CharacterClass

Returns a character class that matches any element with the given Unicode general category. For example, when passed `.uppercaseLetter`, this method is equivalent to `/\p{Uppercase_Letter}/` or `/\p{Lu}/`.

method · iOS 16.0+

symmetricDifference

TypeScript
symmetricDifference(other: CharacterClass): CharacterClass
Swift declaration
func symmetricDifference(_ other: CharacterClass) -> CharacterClass

Returns a character class matching elements in one or the other, but not both, of this class and the given class.

get · iOS 16.0+

regex

TypeScript
get regex(): SDKHandle
Swift declaration
var regex: Regex<Substring> { get }

The regular expression represented by this component.

method · iOS 16.0+

union

TypeScript
union(other: CharacterClass): CharacterClass
Swift declaration
func union(_ other: CharacterClass) -> CharacterClass

Returns a character class from the union of this class and the given class.

get · iOS 16.0+

inverted

TypeScript
get inverted(): CharacterClass
Swift declaration
var inverted: CharacterClass { get }

A character class that matches any character that does not match this character class. For example, you can use the `inverted` property to create a character class that excludes a specific group of characters: let validCharacters = CharacterClass("a"..."z", .anyOf("-_")) let invalidCharacters = validCharacters.inverted let username = "user123" if username.contains(invalidCharacters) { print("Invalid username: '\(username)'") } // Prints "Invalid username: 'user123'"

Skipped declarations

No declarations were skipped in this snapshot.

All RegexBuilder types →