|
|||||
Character classes | |||||
Prerequisite Concepts |
Character classes are patterns that are matched by single characters selected from a programmer-specified set.
Character classes are usually enclosed by square brackets. In their simplest form, the brackets enclose a string. The pattern matches if the next input character is any of the characters that appear in the string.
For example, the following pattern matches any of the characters representing the four usual arithmetic operators:
["+-*/"]
Note the significance of the brackets: while find "\par"
matches a four-character string, find ["\par"]
matches one of four characters.
The "%n" character is not valid when a newline sequence of two or more characters has been specified with the newline
declaration. The formats "%_" and "%t" are always allowed, because they always represent a string of one character.
Prerequisite Concepts Pattern matching |
---- |