]>
Book Contents Previous Section 9.8 Character Next Section 9.10 CliffordAlgebra Book Index

## 9.9 CharacterClass

The CharacterClass domain allows classes of characters to be defined and manipulated efficiently. Character classes can be created by giving either a string or a list of characters.

cl1 := charClass [char "a", char "e", char "i", char "o", char "u", char "y"]

"aeiouy"

Type: CharacterClass
cl2 := charClass "bcdfghjklmnpqrstvwxyz"

"bcdfghjklmnpqrstvwxyz"

Type: CharacterClass

A number of character classes are predefined for convenience.

digit()

"0123456789"

Type: CharacterClass
hexDigit()

"0123456789ABCDEFabcdef"

Type: CharacterClass
upperCase()

"ABCDEFGHIJKLMNOPQRSTUVWXYZ"

Type: CharacterClass
lowerCase()

"abcdefghijklmnopqrstuvwxyz"

Type: CharacterClass
alphabetic()

"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

Type: CharacterClass
alphanumeric()

"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

Type: CharacterClass

You can quickly test whether a character belongs to a class.

member?(char "a", cl1)

true

Type: Boolean
member?(char "a", cl2)

false

Type: Boolean

Classes have the usual set operations because the CharacterClass domain belongs to the category FiniteSetAggregate(Character).

intersect(cl1, cl2)

"y"

Type: CharacterClass
union(cl1,cl2)

"abcdefghijklmnopqrstuvwxyz"

Type: CharacterClass
difference(cl1,cl2)

"aeiou"

Type: CharacterClass
intersect(complement(cl1),cl2)

"bcdfghjklmnpqrstvwxz"

Type: CharacterClass

You can modify character classes by adding or removing characters.

insert!(char "a", cl2)

"abcdfghjklmnpqrstvwxyz"

Type: CharacterClass
remove!(char "b", cl2)

"acdfghjklmnpqrstvwxyz"

Type: CharacterClass

For more information on related topics, see CharacterXmpPage and StringXmpPage .

Book Contents Previous Section 9.8 Character Next Section 9.10 CliffordAlgebra Book Index