diff --git a/dev_files/simple.py b/dev_files/simple.py new file mode 100644 index 0000000..c43360b --- /dev/null +++ b/dev_files/simple.py @@ -0,0 +1,9 @@ +import logging + +from unit_parse import parser, logger + +logger.setLevel(logging.DEBUG) + +result = parser("3.6E+00004 mg/L") +print(result) + diff --git a/setup.cfg b/setup.cfg index a563bfd..30bf7a8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = unit_parse -version = 0.1.6 +version = 0.1.7 description = Parse units from strings. From mess to order! long_description = file: README.md long_description_content_type = text/markdown diff --git a/src/unit_parse/pre_processing_substitution.py b/src/unit_parse/pre_processing_substitution.py index a1c9ea0..ba93887 100644 --- a/src/unit_parse/pre_processing_substitution.py +++ b/src/unit_parse/pre_processing_substitution.py @@ -192,8 +192,8 @@ def sub_sci_notation(text_in: str) -> str: text_in = text_in.replace(exp, exp_new) # remove leading zero in powers ( 5*10**-05 --> 5*10**-5) - text_in = re.sub('(?<=[*]{2}[-])0(?=[0-9])', "", text_in) # neg. power - text_in = re.sub('(?<=[*]{2})0(?=[0-9])', "", text_in) # pos. power + text_in = re.sub('(?<=[*]{2}[-])0+(?=[0-9])', "", text_in) # neg. power + text_in = re.sub('(?<=[*]{2})0+(?=[0-9])', "", text_in) # pos. power return text_in.strip() diff --git a/tests/test_pre_processing_substitution.py b/tests/test_pre_processing_substitution.py index 8ba769a..5e31c8d 100644 --- a/tests/test_pre_processing_substitution.py +++ b/tests/test_pre_processing_substitution.py @@ -72,6 +72,7 @@ def test_remove_words(input_, output_): ['5.3e1 g/mol', '5.3*10**1 g/mol'], ['5.3E1 g/mol', '5.3*10**1 g/mol'], ['5.3 109 g/mol', '5.3*10**9 g/mol'], + ["3.6E+00004 mg/L", "3.6*10**4 mg/L"], # negative control (no changes made) ['5.3*10**1 g/mol', '5.3*10**1 g/mol'],