StructureRegexBuilder5.9.0
CharacterClass
A class of characters that match in a regex.
- iOS
- 16.0+
- macOS
- 13.0+
- tvOS
- 16.0+
- watchOS
- 9.0+
struct CharacterClass
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.
Citizens in RegexBuilder
Conformances
protocol RegexComponent
A type that represents a regular expression.
Members
static func generalCategory(Unicode
.GeneralCategory) -> CharacterClass Returns a character class that matches any element with the given Unicode general category.
var inverted: CharacterClass
A character class that matches any character that does not match this character class.
var regex: Regex<Substring>
func intersection(CharacterClass
) -> CharacterClass Returns a character class from the intersection of this class and the given class.
func subtracting(CharacterClass
) -> CharacterClass Returns a character class by subtracting the given class from this class.
func symmetricDifference(CharacterClass
) -> CharacterClass Returns a character class matching elements in one or the other, but not both, of this class and the given class.
func union(CharacterClass
) -> CharacterClass Returns a character class from the union of this class and the given class.
Features
init(CharacterClass, CharacterClass...
) Creates a character class that combines the given classes in a union.
static var any: CharacterClass
A character class that matches any element.
static var anyGraphemeCluster: CharacterClass
A character class that matches any single
Character
, or extended grapheme cluster, regardless of the current semantic level.static var anyNonNewline: CharacterClass
A character class that matches any element that isn’t a newline.
static var digit: CharacterClass
A character class that matches any digit.
static var hexDigit: CharacterClass
A character class that matches any hexadecimal digit.
static var horizontalWhitespace: CharacterClass
A character class that matches any element that is classified as horizontal whitespace.
static var newlineSequence: CharacterClass
A character class that matches any newline sequence.
static var verticalWhitespace: CharacterClass
A character class that matches any element that is classified as vertical whitespace.
static var whitespace: CharacterClass
A character class that matches any element that is classified as whitespace.
static var word: CharacterClass
A character class that matches any element that is a “word character”.
static func anyOf<S>(S
) -> CharacterClass Returns a character class that matches any character in the given string or sequence.
static func anyOf<S>(S
) -> CharacterClass Returns a character class that matches any Unicode scalar in the given sequence.