More Atoms
Atoms that exactly match a character are the simplest atoms that can
be used in a pattern facet. The other
atoms that can be used in
pattern facets are special characters, a wildcard
that matches any character, or predefined and user-defined character
classes.
Special Characters
Table 9-1 shows the list of atoms that match a single character, exactly like the characters you’ve already seen, but they also correspond to characters that must be escaped or (for the first three characters on the list) that are just provided for convenience.
|
Character |
Description |
\n |
Newline (can also be written as 
 — because it’s an XML document). |
\r |
Carriage return (can also be written as 
). |
\t |
Tabulation (can also be written as 	) |
\\ |
Character \ |
\| |
Character | |
\. |
Character . |
\- |
Character - |
\^ |
Character ^ |
\? |
Character ? |
\* |
Character * |
\+ |
Character + |
\{
|
Character { |
\} |
Character } |
\( |
Character ( |
\) |
Character ) |
\[ |
Character [ |
\] |
Character ] |
Wildcard
The dot
character (.) has a special meaning;
it’s a
wildcard
atom
that matches any valid XML characters except newlines and carriage
returns. As with any atom, a dot may be followed by an optional
quantifier; .* (dot, asterisk) is a common
construct to match zero or more occurrences of any character. To
illustrate the usage of .* (and the fact that the
pattern facet is a Swiss Army knife), a
pattern facet can define the integers that are multiples of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access