|
|||||
Character set ranges | |||||
Prerequisite Concepts |
Ranges of characters can be specified inside a character class by specifying the initial character of the range, the to
keyword, and the final character of the range. For example, the following code fragment matches any character between the lowercase letters "a" and "z":
find ["a" to "z"]
Ranges can be combined with or excluded from other things in a character set, including other ranges. For example, the following code fragment matches any character between the lowercase letters "a" and "z" as well as the characters ".", ",", or "?"; it does not match the lowercase letters between "i" and "n" or the lowercase letter "t":
find ["a" to "z" | ".,?" except "i" to "n" | "t"]
Care must be taken when using character set ranges because the letters of the alphabet are not always contiguous in a character set. In the EBCDIC character encoding, for example, there are non-alphabetic characters between "A" and "Z".
Prerequisite Concepts Character classes Pattern matching |
---- |