Match units with numeric multiplier e.g. "1000 lbf"
Previously we only find units with contiguous non-whitespace
so e.g. "1000 lbf" would be parsed as unit "1000" and value "lbf".
This change allows a single whitespace character separating a
numeric value from another to be parsed as a single unit.
@@ -962,12 +962,17 @@ def configure_metadata_patterns(line, section_name):
# Default return value
patterns = []
- # Default regular expressions for name, unit, value and desc fields
+ # Default regular expressions for name, value and desc fields
name_re = r"\.?(?P<name>[^.]*)\."
- unit_re = r"(?P<unit>[^\s]*)"
value_re = r"(?P<value>.*):"
desc_re = r"(?P<descr>.*)"
+ # Default regular expression for unit field. Note that we
+ # attempt to match "1000 psi" as a special case which allows
+ # a single whitespace character, in contradiction to the LAS specification
+ # See GitHub issue #363 for details.
+ unit_re = r"(?P<unit>([0-9]+\s)?[^\s]*)"
+
# Alternate regular expressions for special cases
value_without_colon_delimiter_re = r"(?P<value>[^:]*)"
value_with_time_colon_re = (
