The align operators will cause spaces (or specified fill character)
to be stripped from the value. Similarly width is not enforced; it
just indicates there may be whitespace or “0”s to strip.

The “#” format character is handled automatically by d, b, o and x -
that is: if there is a “0b”, “0o” or “0x” prefix respectively, it’s
handled. For “d” any will be accepted, but for the others the correct
prefix must be present if at all. Similarly number sign is handled
automatically.

The types supported are a slightly different mix to the format() types. Some
format() types come directly over: “d”, “n”, “%”, “f”, “e”, “b”, “o” and “x”.
In addition some regular expression character group types “D”, “w”, “W”, “s” and
“S” are also available.

The “e” and “g” types are case-insensitive so there is not need for
the “E” or “G” types.

Note that the “center” alignment does not test to make sure the value is
centered - it just strips leading and trailing whitespace.

Some notes for the date and time types:

the presence of the time part is optional (including ISO 8601, starting
at the “T”). A full datetime object will always be returned; the time
will be set to 00:00:00. You may also specify a time without seconds.

when a seconds amount is present in the input fractions will be parsed
to give microseconds.

except in ISO 8601 the day and month digits may be 0-padded.

the date separator for the tg and ta formats may be “-” or “/”.

named months (abbreviations or full names) may be used in the ta and tg
formats in place of numeric months.

as per RFC 2822 the e-mail format may omit the day (and comma), and the
seconds but nothing else.

hours greater than 12 will be happily accepted.

the AM/PM are optional, and if PM is found then 12 hours will be added
to the datetime object’s hours amount - even if the hour is greater
than 12 (for consistency.)

except in ISO 8601 and e-mail format the timezone is optional.

named timezones are not handled yet.

Note: attempting to match too many datetime fields in a single parse() will
currently result in a resource allocation issue. A TooManyFields exception
will be raised in this instance. The current limit is about 15. It is hoped
that this limit will be removed one day.

Result Objects

The result of a parse() operation is either None (no match) or a
Result instance.

The Result instance has three attributes:

fixed

A tuple of the fixed-position, anonymous fields extracted from the input.

named

A dictionary of the named fields extracted from the input.

spans

A dictionary mapping the names and fixed position indices matched to a
2-tuple slice range of where the match occurred in the input.
The span does not include any stripped padding (alignment or width).

Custom Type Conversions

If you wish to have matched fields automatically converted to your own type you
may pass in a dictionary of type conversion information to parse() and
compile().

The converter will be passed the field string matched. Whatever it returns
will be substituted in the Result instance for that field.

Your custom type conversions may override the builtin types if you supply one
with the same identifier.