namedFieldGroupToRegex generates regular expressions for matching fields in named
field-group to field names in a header line. (Private function.)
One regex is generated for a single field, two are generated for a range. These are
returned as a tuple with a pair of regex instances. The first regex is used for
single field entries and the first entry of range. The second regex is filled with
the second entry of a range and is empty otherwise. (Test with 'empty()'.)
This routine converts all field-list escape and wildcard syntax into the necessary
regular expression syntax. Backslash escaped characters are converted to their plain
characters and asterisk wildcarding (glob style) is converted to regex syntax.
Regular expressions include beginning and end of string markers. This is intended for
matching field names after they have been extracted from the header line.
Most field-group syntax errors requiring end-user error messages should be detected
elsewhere in field-list processing. The exception is field-names with a non-escaped
leading or trailing hyphen. A user-appropriate error message is thrown for this case.
Other erroneous inputs result in both regex's set empty.
There is no detection of numeric field-groups. If a numeric-field group is passed in
it will be treated as a named field-group and regular expressions generated.
namedFieldGroupToRegex generates regular expressions for matching fields in named field-group to field names in a header line. (Private function.)
One regex is generated for a single field, two are generated for a range. These are returned as a tuple with a pair of regex instances. The first regex is used for single field entries and the first entry of range. The second regex is filled with the second entry of a range and is empty otherwise. (Test with 'empty()'.)
This routine converts all field-list escape and wildcard syntax into the necessary regular expression syntax. Backslash escaped characters are converted to their plain characters and asterisk wildcarding (glob style) is converted to regex syntax.
Regular expressions include beginning and end of string markers. This is intended for matching field names after they have been extracted from the header line.
Most field-group syntax errors requiring end-user error messages should be detected elsewhere in field-list processing. The exception is field-names with a non-escaped leading or trailing hyphen. A user-appropriate error message is thrown for this case. Other erroneous inputs result in both regex's set empty.
There is no detection of numeric field-groups. If a numeric-field group is passed in it will be treated as a named field-group and regular expressions generated.