The templates used to match FITS keywords are normally composed
of literal characters, which must match the keyword exactly
(apart from case). However, a template may also contain "field
specifiers" which can match a range of possible characters. This
allows you to search for keywords that contain (for example)
numbers, where the digits comprising the number are not known in
advance.
A field specifier starts with a "%" character. This is followed
by an optional single digit (0 to 9) specifying a field
width. Finally, there is a single character which specifies the
type of character to be matched, as follows:
- "c": matches all upper case letters,
- "d": matches all decimal digits,
- "f": matches all characters which are permitted within a FITS
keyword (upper case letters, digits, underscores and hyphens).
If the field width is omitted, the field specifier matches one
or more characters. If the field width is zero, it matches zero
or more characters. Otherwise, it matches exactly the number of
characters specified. In addition to this:
- The template "%f" will match a blank FITS keyword consisting
of 8 spaces (as well as matching all other keywords).
- A template consisting of 8 spaces will match a blank keyword
(only).
For example:
- The template "BitPix" will match the keyword "BITPIX" only.
- The template "crpix%1d" will match keywords consisting of
"CRPIX" followed by one decimal digit.
- The template "P%c" will match any keyword starting with "P"
and followed by one or more letters.
- The template "E%0f" will match any keyword beginning with "E".
- The template "%f" will match any keyword at all (including a
blank one).