:py:mod:`maha.rexy.templates.expression` ======================================== .. py:module:: maha.rexy.templates.expression Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: maha.rexy.templates.expression.Expression .. py:class:: Expression(pattern, pickle = False) Regex pattern holder. :param pattern: Regular expression pattern. :type pattern: str :param pickle: If ``True``, the compiled pattern will be pickled. This is useful to save compilation time for large patterns. :type pickle: bool .. py:attribute:: pattern :annotation: :str Regular expersion(s) to match .. py:method:: compile(self) Compile the regular expersion. .. py:method:: from_cache(cls, cache) :classmethod: Load an expression from cache. :param cache: Name of the cache file. :type cache: str :returns: Expression. :rtype: :class:`~.Expression` .. py:method:: search(self, text) Search for the pattern in the input ``text``. :param text: Text to search in. :type text: str :returns: Matched object. :rtype: :class:`regex.Match` .. py:method:: match(self, text) Match the pattern in the input ``text``. :param text: Text to match in. :type text: str :returns: Matched object. :rtype: :class:`regex.Match` .. py:method:: fullmatch(self, text) Match the pattern in the input ``text``. :param text: Text to match in. :type text: str :returns: Matched object. :rtype: :class:`regex.Match` .. py:method:: sub(self, repl, text) Replace all occurrences of the pattern in the input ``text``. :param repl: Replacement string. :type repl: str :param text: Text to replace. :type text: str :returns: Text with replaced occurrences. :rtype: str .. py:method:: parse(self, text) Extract values from the input ``text``. :param text: Text to extract the value from. :type text: str :Yields: :class:`~.ExpressionResult` -- Extracted value.