|
0 |
|
|
1 |
Character constants are surrounded by single quote characters. They match
|
|
2 |
single characters which, however, can be specified in various ways.
|
|
3 |
itemization(
|
|
4 |
it() The simplest form consists of just a single character: the pattern
|
|
5 |
tt('a') matches the character tt(a), the pattern tt('.') matches the
|
|
6 |
dot-character (tt(.) thus loses its meaning of `any character but
|
|
7 |
the newline character');
|
|
8 |
it() Standard escape characters (like tt('\n', '\f', '\b')) are converted
|
|
9 |
to their (single character) ascii-values, matching those characters
|
|
10 |
when they are encountered in the input. Therefore, of the following
|
|
11 |
two rules the second is never matched (with flc() generating a
|
|
12 |
corresponding warning, since both match the newline character):
|
|
13 |
verb(
|
|
14 |
'\n' return 1;
|
|
15 |
\n return 2;
|
|
16 |
)
|
|
17 |
it() Octal numbers, starting with a backslash and consisting of three
|
|
18 |
octal digits are converted to a number matching input characters of
|
|
19 |
those numbers. E.g., tt('\101') is converted to 65, matching ascii
|
|
20 |
character tt(A);
|
|
21 |
it() Likewise, hexadecimal numbers, starting with tt(x) and followed by
|
|
22 |
two hexadecimal digits are converted to a number matching input
|
|
23 |
characters whose values equal those numbers. E.g., tt('\x41') is also
|
|
24 |
matching ascii character tt(A);
|
|
25 |
it() Other escaped single characters match those characters. E.g.,
|
|
26 |
tt('\\') matches the single backslash, tt('\'') matches the single
|
|
27 |
quote character. But also: tt('\F') matches the single tt(F)
|
|
28 |
character, since no special escaped meaning is associated with tt(F).
|
|
29 |
)
|
|
30 |
|
|
31 |
Considering the above, to match character (in this example: except for the
|
|
32 |
newline character) including its surrounding quotes a regular expression
|
|
33 |
consisting of an escaped quote character, followed by any character, followed
|
|
34 |
by a quote character can be used:
|
|
35 |
verb(
|
|
36 |
\'.' // matches characters surrounded by quotes
|
|
37 |
)
|