``renorm`` ========== .. toctree:: :hidden: :maxdepth: 1 api Description ----------- .. include:: ../../README.md :parser: myst :start-after: :end-before: API overview ------------ .. include:: ../../README.md :parser: myst :start-after: :end-before: Installation ------------ .. include:: ../../README.md :parser: myst :start-after: :end-before: Getting Started --------------- Basic example ~~~~~~~~~~~~~ .. include:: ../../README.md :parser: myst :start-after: :end-before: Using Specs in Regular Expressions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. include:: ../../README.md :parser: myst :start-after: :end-before: Below there is an example for a :class:`Num` spec passed as a positional argument. Mind that the regular expression can be constructed with regular capturing groups and that :mod:`renorm` spec is only captured and normalized if inside a capturing group. .. code-block:: Python :caption: ``{@0}`` us = rn.Num(ths="'") p = rn.compile(r"([A-Za-z]+):\s?({@0})", us) m = p.search("total: 1'234.5\n") print(m.groups()) # ('total', 1234.5) .. doctest:: :hide: >>> import renorm as rn >>> us = rn.Num(ths="'") >>> p = rn.compile(r"([A-Za-z]+):\s?({@0})", us) >>> m = p.search("total: 1'234.5\n") >>> print(m.groups()) ('total', 1234.5) Example for a :class:`Num` spec passed as a keyword argument. .. code-block:: Python :caption: ``{@value}`` eu_num = rn.Num(dec=",", ths=" ") p = rn.compile(r"([a-zA-z]+):\s?({@value})", value=eu_num) m = p.search("total: 1 234,5\n") print(m.groups()) # ('total', 1234.5) .. doctest:: :hide: >>> import renorm as rn >>> eu_num = rn.Num(dec=",", ths=" ") >>> p = rn.compile(r"([a-zA-z]+):\s?({@value})", value=eu_num) >>> m = p.search("total: 1 234,5\n") >>> print(m.groups()) ('total', 1234.5) Custom specs ~~~~~~~~~~~~ .. include:: ../../README.md :parser: myst :start-after: :end-before: