Skip to content

Commit

Permalink
Add support for spaces between a value an its unit.
Browse files Browse the repository at this point in the history
I.e. "3.3 nF" is the same as "3.3nF"
  • Loading branch information
set-soft committed Jul 16, 2020
1 parent 4125cda commit 6b96a8e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions kibom/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b96a8e

Please sign in to comment.