From 6b96a8e0a76d0a50cb278bd2ee2e2d16d16693a9 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Thu, 16 Jul 2020 15:14:13 -0300 Subject: [PATCH] Add support for spaces between a value an its unit. I.e. "3.3 nF" is the same as "3.3nF" --- kibom/units.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kibom/units.py b/kibom/units.py index da68c4d..6030249 100644 --- a/kibom/units.py +++ b/kibom/units.py @@ -84,14 +84,14 @@ def groupString(group): # Return a reg-ex string for a list of values def matchString(): - return "^([0-9\.]+)(" + groupString(PREFIX_ALL) + ")*(" + groupString(UNIT_ALL) + ")*(\d*)$" + return r"^([0-9\.]+)\s*(" + groupString(PREFIX_ALL) + ")*(" + groupString(UNIT_ALL) + r")*(\d*)$" def compMatch(component): """ Return a normalized value and units for a given component value string - e.g. compMatch("10R2") returns (10, R) - e.g. compMatch("3.3mOhm") returns (0.0033, R) + e.g. compMatch('10R2') returns (10, R) + e.g. compMatch('3.3mOhm') returns (0.0033, R) """ # Remove any commas