Skip to content
Snippets Groups Projects
Verified Commit 77c97578 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch 'master' of edugit.org:AlekSIS/libs/django-iconify

parents 5d8ef5d3 bd4e0d39
No related branches found
No related tags found
No related merge requests found
import re
def split_css_unit(string: str):
"""Split string into value and unit.
>>> split_css_unit("12px")
(12, 'px')
>>> split_css_unit("1.5em")
(1.5, 'em')
>>> split_css_unit("18%")
(18, '%')
>>> split_css_unit("200")
(200, '')
"""
_value = re.findall("^[0-9.]+", string)
value = float(_value[0]) if "." in _value[0] else int(_value[0])
unit = string[len(_value[0]):]
return value, unit
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment